我想用SQL语句得到查询结果中的的N条记录应该怎么做的?

解决方案 »

  1.   

    select top N * from tab
      

  2.   

    select top N * from tb
      

  3.   

    http://topic.csdn.net/u/20080520/21/eb5585f5-c040-4f36-8784-04811de73e16.html
      

  4.   

    -- select top 1 [ID],[Name,Title from WebSite
    -- where not  [ID] in (select top   11 [ID] from  WebSite order by [ID] asc)  order by [ID] asc
    Declare @strSql Varchar(200),@intTopN int
    Set @intTopN = 11
    Set  @strSql = 'select top 1 [ID],[Name,Title from WebSite where not  [ID] in (select top  '+Cast(@intTopN  As Varchar(10))+'   [ID] from  WebSite order by [ID] asc)  order by [ID] asc'
    Print @strSql
    Exec(@strSql)