//带参数的小列子
if (exists (select * from sys.objects where name = ‘proc_get_Purchasing2‘))
drop proc proc_get_student
go
alter proc proc_get_Purchasing2(@today int)
as
--declare @today int
//申明变量
declare @weeks nvarchar(3)
//设置变量值 set @weeks
set @weeks=case
when @today = 1 then ‘星期一‘
when @today = 2 then ‘星期二‘
else ‘错误‘
end
print @weeks
exec proc_get_Purchasing2 @today =2
//带循环
if (exists (select * from sys.objects where name = ‘proc_get_Purchasing3‘))
drop proc proc_get_Purchasing3
go
create proc proc_get_Purchasing3
as
declare @sum1 int
set @sum1=1
WHILE @sum1<10
begin
set @sum1 [email protected]+1
end
exec proc_get_Purchasing3
时间: 2024-11-15 20:27:54