How to insert into a table with just one IDENTITY column (SQL Express)

前端 未结 2 1766
南旧
南旧 2021-01-03 21:16

Pretty much the same as this question.

But I can\'t seem to get this to work with SQL Server Express in Visual Studio 2008.

Same Table layout, One column wit

2条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-03 22:06

    Instead of trying to rely on some syntax about "DEFAULT VALUES" as the keyword, let the engine help you with that... How about explicitly trying to set ONE of the values, such as

    insert into YourTable ( PickOneField ) values ( "whatever" )
    

    So, even though you are only preping ONE field, the new record by the native engine SHOULD populate the REST of them with their respective default values.

提交回复
热议问题