程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> SqlServer數據庫 >> 關於SqlServer >> sql Set IDENTITY_INSERT的用法

sql Set IDENTITY_INSERT的用法

編輯:關於SqlServer
語法
SET IDENTITY_INSERT [ database.[ owner.] ] { table } { ON | OFF }

參數
database ,是指定的表所駐留的數據庫名稱。

owner
是表所有者的名稱。

table
是含有標識列的表名。

使用舉例子,往數據庫中插入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
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved