sql Set IDENTITY_INSERT的用法
更新時(shí)間:2009年03月30日 11:35:46 作者:
SET IDENTITY_INSERT 允許將顯式值插入表的標(biāo)識(shí)列中。
語法
SET IDENTITY_INSERT [ database.[ owner.] ] { table } { ON | OFF }
參數(shù)
database ,是指定的表所駐留的數(shù)據(jù)庫名稱。
owner
是表所有者的名稱。
table
是含有標(biāo)識(shí)列的表名。
使用舉例子,往數(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
是含有標(biāo)識(shí)列的表名。
使用舉例子,往數(shù)據(jù)庫中插入100萬條記錄。
復(fù)制代碼 代碼如下:
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
相關(guān)文章
不固定參數(shù)的存儲(chǔ)過程實(shí)現(xiàn)代碼
我們知道存儲(chǔ)過程是不支持不固定參數(shù)情況的(包括數(shù)組參數(shù)),可是有時(shí)候我們的參數(shù)又必須是不固定的,怎么辦呢?2011-01-01sql server的一個(gè)有趣的bit位運(yùn)算分享
sql server中沒有bool類型,而是用bit類型來表示bool值,估計(jì)是為了節(jié)省存儲(chǔ)空間,下面為大家介紹下這個(gè)有趣的bit位運(yùn)算,感興趣的朋友可以參考下2013-09-09將一個(gè)表中個(gè)某一列修改為自動(dòng)增長的方法
如果表中沒有數(shù)據(jù)可以使用 drop column然后再add column,如果存在一部分?jǐn)?shù)據(jù)可以使用本文提供的第二種解決方法2014-09-09MSSQL監(jiān)控?cái)?shù)據(jù)庫的DDL操作(創(chuàng)建,修改,刪除存儲(chǔ)過程,創(chuàng)建,修改,刪除表等)
下面就是一個(gè)解決上述問題的方案,我們通過創(chuàng)建一個(gè)表DatabaseLog和DDL觸發(fā)器來解決問題,首先在msdb數(shù)據(jù)庫里面新建一個(gè)表DatabaseLog,用來保存DDL觸發(fā)器獲取的信息2013-08-08SQLServer 數(shù)據(jù)庫中如何保持?jǐn)?shù)據(jù)一致性
復(fù)制是SQLServer數(shù)據(jù)庫中保持?jǐn)?shù)據(jù)一致性的一種手段。2009-06-06SQL Server數(shù)據(jù)庫重命名、數(shù)據(jù)導(dǎo)出的方法說明
這篇文章主要介紹了SQL Server數(shù)據(jù)庫重命名、數(shù)據(jù)導(dǎo)出、更改數(shù)據(jù)庫所有者的方法說明,大家參考使用吧2013-11-11