如何仅将一个IDENTITY列插入到表中? [英] How to insert into a table with just one IDENTITY column?
本文介绍了如何仅将一个IDENTITY列插入到表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
(请在尝试回答考虑下面的MS-SQL表,称为GroupTable:
Consider the following MS-SQL table, called GroupTable:
GroupID
-------
1
2
3
其中GroupID是主键,是身份"列.
where GroupID is the primary key and is an Identity column.
如何使用IDENTITY_INSERT ON 不在表中插入新行(从而生成新ID)?
How do you insert a new row into the table (and hence generate a new ID) without using IDENTITY_INSERT ON?
请注意,
INSERT INTO GroupTable() Values ()
...将无法正常工作.
... won't work.
我们在这里谈论的是SQL 2005或SQL 2008.
edit: we're talking SQL 2005 or SQL 2008 here.
推荐答案
这应该有效:
INSERT INTO GroupTable DEFAULT VALUES
这篇关于如何仅将一个IDENTITY列插入到表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文