首先看看带默认值的存储过程吧:
格式这么写
create proc productscount @categoryid int=5,@c varchar(10)='%a%'
as
select sum(unitprice) from products where categoryid=@categoryid and productname like @c
像下面这么调用:
exec productscount @categoryid=1,@c='%a%'
如果用exec productscount,后面不带参数,那么就会使用默认参数