Posts

Showing posts with the label identity

How to insert into a table with just one IDENTITY column?

Image
Clash Royale CLAN TAG #URR8PPP How to insert into a table with just one IDENTITY column? (Came up with this question in the course of trying to answer this other one) Consider the following MS-SQL table, called GroupTable: where GroupID is the primary key and is an Identity column. How do you insert a new row into the table (and hence generate a new ID) without using IDENTITY_INSERT ON? Note that this: INSERT INTO GroupTable() Values () ... won't work. edit: we're talking SQL 2005 or SQL 2008 here. 4 Answers 4 This should work: INSERT INTO GroupTable DEFAULT VALUES I can't get this to work with Visual Studio 2008/SQL Express 2005. Any ideas? Same table layout, one column, primary key, identity(1,1). – Thomas Sandberg Aug 31 '09 at 18:27 ...