In SQL Server 2000 or above is there anyway to handle an auto generated primary key (identity) column when using a statement like the following?
Insert Into TableName Values(?, ?, ?)
My goal is to NOT use the column names at all.
By default, if you have an identity column, you do not need to specify it in the VALUES section. If your table is:
ID NAME ADDRESS
Then you can do:
INSERT INTO MyTbl VALUES ('Joe', '123 State Street, Boston, MA')
This will auto-generate the ID for you, and you don't have to think about it at all. If you SET IDENTITY_INSERT MyTbl ON
, you can assign a value to the ID column.