create proc dbo.mathtutor
@m1 smallint,--要输入的值
@m2 smallint,--要输入的值
@result smallint output --要输出的值
as
set @result =@m1+@m2 --如果在AS后面还要输入数值,那么就是存储过程内部的数值!
go
delcare @answer smallint
exec mathtutor 5,6, @answer output
select 'the result is:',@answer
@m1 smallint,--要输入的值
@m2 smallint,--要输入的值
@result smallint output --要输出的值
as
set @result =@m1+@m2 --如果在AS后面还要输入数值,那么就是存储过程内部的数值!
go
delcare @answer smallint
exec mathtutor 5,6, @answer output
select 'the result is:',@answer
可用@@ROWCOUNT 捉到。
return 1
通常使用return返回值然后退出存储过程,return后面可以带值、变量,如果什么不带返回0正常返回结果就是select语句的查询结果,不包括使用select的赋值语句如果使用set nocount on进行设置的,则只返回最后一个查询结果
储存过程中的任何返回表的select语句得到的结果就是这个储存过程的返回表,可以有多个