想取头几条:select top @count * from [table]
想判断参数:if @id=0
               select * from [table]
这两句都有错的!  应该怎么改

解决方案 »

  1.   

    exec ('select top '+ltrim(@count)+' * from [table]') 2000 top 后面不能直接跟变量
      

  2.   

    select top (@count) * from [table]
      

  3.   

    1.
    declare @count int
    declare @sql varchar(8000)
    set @count=20
    set @sql='select top '+ltrim(@count)+' * from [table]'
    exec(@sql)2.
    declare @id int set @id=0
    if @id=0
      select * from [Table]