sql Set IDENTITY_INSERT的用法
更新時(shí)間:2009年03月30日 11:35:46 作者:
SET IDENTITY_INSERT 允許將顯式值插入表的標(biāo)識(shí)列中。
語(yǔ)法
SET IDENTITY_INSERT [ database.[ owner.] ] { table } { ON | OFF }
參數(shù)
database ,是指定的表所駐留的數(shù)據(jù)庫(kù)名稱。
owner
是表所有者的名稱。
table
是含有標(biāo)識(shí)列的表名。
使用舉例子,往數(shù)據(jù)庫(kù)中插入100萬(wàn)條記錄。
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ù)庫(kù)名稱。
owner
是表所有者的名稱。
table
是含有標(biāo)識(shí)列的表名。
使用舉例子,往數(shù)據(jù)庫(kù)中插入100萬(wàn)條記錄。
復(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)文章
SQL語(yǔ)句練習(xí)實(shí)例之二——找出銷售冠軍
在公司中,老板走進(jìn)來(lái),要一張每個(gè)地區(qū)銷量前3名的銷售額與銷售員的報(bào)表2011-10-10
SQL Server中統(tǒng)計(jì)每個(gè)表行數(shù)的快速方法
這篇文章主要介紹了SQL Server中統(tǒng)計(jì)每個(gè)表行數(shù)的快速方法,本文不使用傳統(tǒng)的count()函數(shù),因?yàn)樗容^慢和占用資源,本文講解的是另一種方法,需要的朋友可以參考下2015-02-02
sqlserver中比較一個(gè)字符串中是否含含另一個(gè)字符串中的一個(gè)字符
sql中比較一個(gè)字符串中是否含有另一個(gè)字符串中的一個(gè)字符的實(shí)現(xiàn)代碼,需要的朋友可以參考下。2010-09-09
驅(qū)動(dòng)程序無(wú)法通過使用安全套接字層(SSL)加密與?SQL?Server?建立安全連接,錯(cuò)誤:“The?serve
這篇文章主要介紹了驅(qū)動(dòng)程序無(wú)法通過使用安全套接字層(SSL)加密與?SQL?Server?建立安全連接,錯(cuò)誤:“The?server?selected?protocol?version?TLS10?is?not?accepted?by?client,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-03-03
多表關(guān)聯(lián)同時(shí)更新多條不同的記錄方法分享
因?yàn)轫?xiàng)目要求實(shí)現(xiàn)一次性同時(shí)更新多條不同的記錄的需求,和同事討論了一個(gè)比較不錯(cuò)的方案,這里供大家參考下2011-10-10

