Orion Adrian
Orion Adrian

Reputation: 19573

What is the SQL Command for inserting into a table that has no non-identity columns

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

Answers (1)

Remus Rusanu
Remus Rusanu

Reputation: 294477

INSERT INTO TableName DEFAULT VALUES;

DEFAULT VALUES: Forces the new row to contain the default values defined for each column.

Upvotes: 6

Related Questions