select top n的用法中n可以是变量吗 ,如 select top @mTop * from table_namne
我写在存储过程中报错啊

解决方案 »

  1.   

    SQL SERVER 2000不支持,SQL SERVER 2005可以
      

  2.   

    sql2000可以用动态语句实现,如:
    exec(select top '+@mTop+' * from table_namne')
      

  3.   

    declare @mTop int
    set @mTop=10declare @Str varchar(8000)
    set @Str='select top ' + cast( @mTop as varchar(10)) + '* from wr'exec (@Str)
      

  4.   

    ==================================
    =  CSDN助手 全面支持CSDN论坛     =
    =  监视、收藏、历史、签名走马灯  =
    ==================================