1. 程式人生 > >SQL SERVER儲存過程批量插入資料庫表資料

SQL SERVER儲存過程批量插入資料庫表資料

CREATEPROCEDURE add_UserInfo
AS
DECLARE@userCodeVARCHAR(30)
DECLARE@userNameVARCHAR(30)

DECLARE@userCode_baseVARCHAR(30)
DECLARE@countINTEGER
DECLARE@indexINTEGER
DECLARE@rand1INTEGER
DECLARE@rand2INTEGER
SET@userCode_base='qs_'
SET@userName='userName'
SET@count=100000
SET@index=10000

WHILE@index<@count
BEGIN
 
SET@userCode
=@userCode_base+CONVERT(VARCHAR,@index)
 
SET@rand1=convert(int,rand()*5)
 
SET@rand2=convert(int,rand()*5)
 
INSERTINTO userInfo (userCode,roleType,groupID,userName,text1,text2,text3)
 
VALUES (@userCode,@rand1,@rand2,@userName,'aokei kaol jof','','aokei kaol jof')
 
 
SET@index=@index+1
END
GO