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
  • 732,580
  • 175
  • 1,330
  • 1,459
e_i_pi
  • 4,590
  • 4
  • 27
  • 45

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
  • 43,250
  • 3
  • 46
  • 71