学习一下存储过程

USE [books]
GO
/****** Object: StoredProcedure [dbo].[mybookssearch] Script Date: 2013/2/5 
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[mybookssearch]
@x varCHAR(10),
@t1 date,
@t2 date
as
BEGIN
SELECT stock_info.库存ID,stock_info.图书ID,book_info.图书名称,book_info.作者,book_info.出版时间,book_info.出版社
FROM dbo.book_info INNER join stock_info
on dbo.book_info.图书ID=stock_info.图书ID
WHERE (图书名称 LIKE '%'+@x+'%') AND (出版时间 BETWEEN @t1 AND @t2)
END

执行的时候:

USE [books]
GO

DECLARE @return_value int

EXEC @return_value = [dbo].[mybookssearch]
@x = N'j',
@t1 = '2001-01-01',
@t2 = '2017-01-01'

SELECT 'Return Value' = @return_value

 

posted @ 2013-02-05 13:21  绝对菜鸟  阅读(156)  评论(0编辑  收藏  举报