create proc 名字@num1 int, --变量@num2 int --变量@count int output --变量,返回值asbeginselect @num1+@num2 --执行的函数 sql语句end
3.修改
alter proc 4.使用--第一种方式exec usp_numberAdd @num1=10,@num2=20--第二种方式declare @n1 int=21,@n2 int=32exec usp_numberAdd @num1=@n1,@num2=@n2--第三种方式exec usp_numberAdd 30,20
5.示例(分页)
create proc usp_fenye@ye int,@dijiye int,@sumPage int outputasbegin set @sumPage=(CEILING((select count(*) from student)*1.0/@ye)) select * from (select *,序号=ROW_NUMBER()over(order by tsid) from student) as newstudent where 序号 between (@dijiye-1)*@ye+1 and @dijiye*@yeenddeclare @sum intexec usp_fenye 2,3,@sum outputselect @sum