sql Set IDENTITY_INSERT的用法

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

? 版權聲明
THE END
喜歡就支持一下吧
點贊10 分享