Insert row with defaults or zeros only

I have a table with a different number of columns of different names.

All columns are one of the following:

  • identification columns
  • NULL columns
  • or have a default value

Now I want to insert a new row into this table and read its contents.

I tried all of the following:

INSERT INTO globalsettings() VALUES()
INSERT INTO globalsettings VALUES()
INSERT INTO globalsettings VALUES
INSERT INTO globalsettings

Am I missing the correct syntax or can't insert a string with all standards?

+4
source share
3 answers
INSERT INTO globalsettings DEFAULT VALUES;

You can find a description here: http://msdn.microsoft.com/en-us/library/ms174335.aspx

+9
source

You can do something like this:

INSERT INTO globalsettings (Column1) VALUES (DEFAULT)

Column1 .

+1

The number of columns in the table should be equal to the number of values ​​if you decide not to use the column names in the statement. For example, if you have 4 columns in which the first is the identifier, the second and third are NULL, and the fourth is int 0 by default.

You can do

INSERT INTO globalSettings DEFAULT VALUES

OR

You can specify all values:

INSERT INTO globalSettings Values (NULL, NULL, 0)

OR

You can specify columns, and the rest are null or 0 by default.

INSERT INTO globalSettings(secondColumn) VALUES (Default)

OR

  INSERT INTO globalSettings(secondColumn) VALUES (null)

This will insert a row with 1, null, null, 0

You cannot insert into a table without specifying what you want to insert.

+1
source

All Articles