Hi,
Question:
I have a table with only one column. The column is of smallint datatype and is specified as identity. How to insert into that table?
Answer:
Let’s discuss this with a example.
Create a table with only one column, with identity.
CREATETABLE TEST(LogNo smallintidentity)
If you try to insert into the table using the normal insert command, you’ll get an error.
INSERTINTO TEST(LogNo)VALUES ()
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ')'.
Below is the insert command to achieve this
INSERTINTO TEST DEFAULTVALUES
Thanks,
Selvaraj M.
Follow me at @MSSQLDB