1 select identity(int,1,1) as idd,* into #t from yourtable
select * from youttable where idd=10
2 select count(*)总数 from yourtable

解决方案 »

  1.   

    SET NOCOUNT OFF
    USE pubs
    IF EXISTS (SELECT name FROM sysindexes 
          WHERE name = 'au_id_ind')
       DROP INDEX authors.au_id_ind
    GO
    USE pubs
    CREATE INDEX au_id_ind
       ON authors (au_id)
    GO
      

  2.   

    select identity(int,1,1) as idd,* into #t from test
    select * from test where idd=10  
     但是有服务器: 消息 207,级别 16,状态 3,行 1
    列名 'idd' 无效。
      

  3.   

    统计行数:
    select count(*) from 表
      

  4.   

    取第10条记录
    select myid=identity(int,1,1),* into #tb from test
    select * from #tb where myid=10
      

  5.   

    to zjcxc(邹建) 
    select myid=identity(int,1,1),* into #tb from test
    select * from #tb where myid=10
    可以说说这样sql语句是怎样理解吗?
      

  6.   

    创建一个与原表记录相同,包含记录号(用标识字段来实现)的临时表
    select myid=identity(int,1,1),* into #tb from test--查询记录号为10的记录
    select * from #tb where myid=10--查询结束后,最好加上删除临时表的语句
    drop table #tb
      

  7.   

    如果该表有关键字段,则象下面这样写:
    Select * from yourTable a
     where (select count(*) from yourTable where KeyField <= a.KeyField) = 10
    KeyField是你的表的关键字段的名称 yourtable是表名
    如果该表没有关键字段,则想下面这样写:
    Select identity(int,1,1) as id,* into #temp from yourTable 
    Select * from #temp where id = 10
    drop table #temp