SQL SERVER儲存過程批量插入資料庫表資料
阿新 • • 發佈:2018-12-29
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
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
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