1

Suppose you have a table in SQL Server declared in the following manner:

CREATE TABLE my_table 
(
    id INT IDENTITY(1,1) PRIMARY KEY
);

How do you INSERT into this table? I have tried the following, all to no avail:

INSERT INTO my_table;
INSERT INTO my_table () VALUES ();
INSERT INTO my_table SELECT NULL;
marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425
e_i_pi
  • 4,271
  • 4
  • 25
  • 44

1 Answers1

5

You can specify DEFAULT VALUES as long as all columns are auto-generated, allow null, or have default constraints:

INSERT INTO dbo.my_table DEFAULT VALUES;
Dan Guzman
  • 38,909
  • 3
  • 38
  • 62