存储过程怎么取到前几条数据
CREATE PROCEDURE [tm_select_new]
@SMT_scasort int
AS
select top 8 SMT_id,SMT_scatitle,SMT_begindate,SMT_yp_id
from SMT_sca where SMT_key=1 and SMT_key1=1
and SMT_key2=1 and SMT_scasort=@SMT_scasort
order by SMT_key3 desc,SMT_id desc
GO
我想把 8 改成一个 参数 调用的时候 传入一个值 怎么处理这个存储过程 谢谢
------解决方案--------------------CREATE PROCEDURE [tm_select_new]
@SMT_scasort int,
@topn int
AS
set rowcount @topn
select SMT_id,SMT_scatitle,SMT_begindate,SMT_yp_id
from SMT_sca where SMT_key=1 and SMT_key1=1
and SMT_key2=1 and SMT_scasort=@SMT_scasort
order by SMT_key3 desc,SMT_id desc
GO