exec('select top '+ @n+' * from table1') //n 是传来的参数
假如要取第10行
select top 1 * from (select top 10 * from T0 order by ID )T1 order by ID desc
ORACLE select * from (select ROW_NMBER () over(order by column_name) as rn from table_name ) tb where tb.rn =? 你的行号
来排序之后再检索
看你是什么数据库? db2/oracle/sql server 2005以上可以, mysql变通下应该也行
exec('select top '+ @i+' * from table1')