How to insert into a one column (identity) table

Last updated on April 15th, 2024

Tables with just one column, which has been specified as identity columns, are not very common, and inserting data into them might be a bit tricky. To do that you need to use DEFAULT value without parenthesis. For example, let’s create the table IdentityTable:

CREATE TABLE IdentityTable
(
tableID INT PRIMARY KEY IDENTITY(1,1) NOT NULL
)

To insert data, you need to use the following statement:

INSERT INTO IdentityTable DEFAULT VALUES

Leave a Comment

Your email address will not be published. Required fields are marked *