根据Parameter中的值选择顶行

时间:2015-03-18 19:28:04

标签: sql-server-2008

我想从存储过程中选择TOP行。要选择的行数具有stroed proc的参数。
像这样的东西:

declare @rowCount int 
SET @rowCount = 5
select top @rowCount * from ActivityLog 

这不执行,我该怎么做呢?

1 个答案:

答案 0 :(得分:1)

使用top()

select top (@rowCount) * from ActivityLog 
相关问题