sql Set IDENTITY_INSERT的用法
更新時間:2009年03月30日 11:35:46 作者:
SET IDENTITY_INSERT 允許將顯式值插入表的標識列中。
語法
SET IDENTITY_INSERT [ database.[ owner.] ] { table } { ON | OFF }
參數(shù)
database ,是指定的表所駐留的數(shù)據(jù)庫名稱。
owner
是表所有者的名稱。
table
是含有標識列的表名。
使用舉例子,往數(shù)據(jù)庫中插入100萬條記錄。
set identity_insert sosuo8database on
declare @count int
set @count=1
while @count<=1000000
begin
insert into sosuo8database(id,userName,userPWD,userEmail) values(@count,'ahuinan','ahuinan','sosuo8.com') set @count=@count+1
end
set identity_insert sosuo8database off
SET IDENTITY_INSERT [ database.[ owner.] ] { table } { ON | OFF }
參數(shù)
database ,是指定的表所駐留的數(shù)據(jù)庫名稱。
owner
是表所有者的名稱。
table
是含有標識列的表名。
使用舉例子,往數(shù)據(jù)庫中插入100萬條記錄。
復制代碼 代碼如下:
set identity_insert sosuo8database on
declare @count int
set @count=1
while @count<=1000000
begin
insert into sosuo8database(id,userName,userPWD,userEmail) values(@count,'ahuinan','ahuinan','sosuo8.com') set @count=@count+1
end
set identity_insert sosuo8database off
相關文章
MSSQL監(jiān)控數(shù)據(jù)庫的DDL操作(創(chuàng)建,修改,刪除存儲過程,創(chuàng)建,修改,刪除表等)
下面就是一個解決上述問題的方案,我們通過創(chuàng)建一個表DatabaseLog和DDL觸發(fā)器來解決問題,首先在msdb數(shù)據(jù)庫里面新建一個表DatabaseLog,用來保存DDL觸發(fā)器獲取的信息2013-08-08SQLServer 數(shù)據(jù)庫中如何保持數(shù)據(jù)一致性
復制是SQLServer數(shù)據(jù)庫中保持數(shù)據(jù)一致性的一種手段。2009-06-06SQL Server數(shù)據(jù)庫重命名、數(shù)據(jù)導出的方法說明
這篇文章主要介紹了SQL Server數(shù)據(jù)庫重命名、數(shù)據(jù)導出、更改數(shù)據(jù)庫所有者的方法說明,大家參考使用吧2013-11-11