请大家帮我看看,这条存储过程该怎么写
内容:
Create procedure GetIndexNews
@PageSize int = 20,
@Category int
as
SELECT Top @PageSize Newsid,NewsTitle,NewsContent,NewsLink,
UpdatePerson,UpdateDate,PicUrl,NewsFrom,Author
From
Web_News_Info
Where
NewsType = @Category
order by
UpdateDate desc
总是报错
服务器: 消息 170,级别 15,状态 1,过程 GetIndexNews,行 9
第 9 行: '@PageSize ' 附近有语法错误。
好象 Top 后面的写法不对,应该怎么写呢?
------解决方案--------------------Create procedure GetIndexNews
@PageSize int = 20,
@Category int
as
exec( '
SELECT Top '+@PageSize+ ' Newsid,NewsTitle,NewsContent,NewsLink,
UpdatePerson,UpdateDate,PicUrl,NewsFrom,Author
From
Web_News_Info
Where
NewsType = '+@Category+ '
order by
UpdateDate desc
')