存储过程 如何化传递count和keyword
在数据库写存储过程的时候 如何传递一个整数类型@count 到红色字体部分 实现控制返回记录行数
ALTER PROCEDURE dbo.GetNewBook
@count int
AS
SELECT TOP @count *FROM Books ORDER BY PublishDate DESC
RETURN
然后还有 如何传递一个keyword关键字到存储过程
ALTER PROCEDURE dbo.GetSearchKeywordsBykeywordLike
@keyword nvarchar(50)
AS
select top 10 * from SearchKeywords where keyword like '" + keyword + "%' order by SearchCount desc
RETURN
------解决方案--------------------
SQL code
set @sql=N'SELECT TOP '+cast(@count as varchar(20))+' * FROM Books ORDER BY PublishDate DESC'