Reputation: 19573
I have a table that has a single identity column. What is the SQL command for inserting a row into table that only has a single identity column where I want to use the identity column's auto-generation?
I've tried
INSERT INTO TableName
INSERT INTO TableName () VALUES ()
INSERT INTO TableName (Id) VALUES (DEFAULT)
None worked in SQL Server 2008 R2. Id is an identity column.
Upvotes: 2
Views: 183
Reputation: 294477
INSERT INTO TableName DEFAULT VALUES;
DEFAULT VALUES: Forces the new row to contain the default values defined for each column.
Upvotes: 6