create proc usp_helloworld
as
begin
print 'Hello World'
end
create proc usp_book
@name nvarchar(50),
@author nvarchar(50)
as
begin
select * from book where name=@name and author=@author
end
调用 exec usp_book “test”,“book” exec usp_book @name=“test”,@author=“book”
create proc usp_output
@bookname nvarchar(50),
@recordCount int output --关键字代表输出参数
as
begin
select * from hero where bookname=@bookname
--把查询的记录条数赋值给变量@recordCount
set @recordCount = (select count(*) from hero where bookname=@bookname)
end
declare @num int exec usp_output @bookname=‘test’,@recordCount=@num output select @num as table_name