1.根据传入参数查询
CREATE procedure lcstest
@no varchar(255),@callen int
as
select * from detail200911 where no=@no and callen=@callen
GO
执行
exec lcstest @no=2607718,@callen=48
2.带有输出参数
CREATE procedure lcstest
@su int output
as
select @su =sum(callen) from detail200911
GO
执行
declare @su int
execute lcstest @su output
select @su as result
3.传参+输出参数
CREATE procedure lcstest
@no varchar(255),@su int output
as
select @su =sum(callen) from detail200911 where no=@no
GO
执行
declare @su int
execute lcstest @no=2607718,@su=@su output
select @su as result
或
declare @su int
execute lcstest 2607718,@su output
select @su as result
4.使用游标