SET IDENTITY_INSERT 允许将显式值插入表的标识列中。
SET IDENTITY_INSERT [ database.[ owner.] ] { table } { ON | OFF }
database ,是指定的表所驻留的数据库名称。
是表所有者的名称。
是含有标识列的表名。
使用举例子,往数据库中插入100万条记录。
代码如下:
set identity_insert sosuo8database on
declare @count int
set @count=1
while @countbegin
insert into sosuo8database(id,userName,userPWD,userEmail) values(@count,'ahuinan','ahuinan','sosuo8.com') set @count=@count+1
end
set identity_insert sosuo8database off
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn