且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在SQL Server 2005中插入标识列值

更新时间:2022-03-04 01:25:51

1-您不能在表上拥有2个身份密钥.

2-如果您有1个标识列,并且要插入1000条记录,则可以执行以下操作.

1- You can''t have 2 identity key on a table.

2- If you have 1 identity column and you want to insert 1000 records you can do like following.

DECLARE @Counter int
SET @Counter=1
WHILE (@Counter) <= 1000
BEGIN
	-- Wrtie your insert statement here
	SET @Counter = @Counter +1

end



3-如果在这种情况下,如果您的表具有1列类型标识,则可以添加如下所示的行.



3- If you have a table having 1 column of type identity in that case you can add a row like following.

INSERT INTO TABLE_NAME DEFAULT VALUES