SQL server數(shù)據(jù)庫簡單的使用存儲過程,入門級別
?--刪除存儲過程
--drop proc AddProc--此為存儲過程的名字
--go
?--創(chuàng)建存儲過程
create proc AddProc--此為存儲過程的名字,前面帶#的為臨時的存儲過程
@str nvarchar(10)--可選參數(shù),如果沒有參數(shù) as 可不用寫
as?
declare @n int --存儲過程內(nèi)部需要使用的參數(shù),declare創(chuàng)建參數(shù)的關(guān)鍵字
set @n=1;
while(@n<21)
begin
INSERT INTO [dbo].[Users]
? ? ? ? ? ?([Id],[UserName],[LoginName],[Password],[Remark]
? ? ? ? ? ?,[Phone] ,[CreatedBy],[CreatedDateTime])
? ? ?VALUES
? ? ? ? ? ?(@n
? ? ? ? ? ?,'王富貴'+CONVERT(nvarchar(10),@n)+'號'
? ? ? ? ? ?,'王富貴'+CONVERT(nvarchar(10),@n)+'號'
? ? ? ? ? ?,NewID()
? ? ? ? ? ?,'王富貴'+CONVERT(nvarchar(10),@n)+'號 的賬戶'
? ? ? ? ? ?,CONVERT(nvarchar(10),@n)+'2345678'
? ? ? ? ? ?,@str
? ? ? ? ? ?,GETDATE())
set @n=@n+1
end
go
調(diào)用此存儲過程??文章來源:http://www.zghlxwxcb.cn/news/detail-458625.html
exec AddProc '系統(tǒng)管理員'? --如果有多個參數(shù)則用都好分隔文章來源地址http://www.zghlxwxcb.cn/news/detail-458625.html
到了這里,關(guān)于SQL server數(shù)據(jù)庫簡單的使用存儲過程的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!