select count(*),字段1,字段2,....
from table
OR
select count(*),字段1
from table
group by 字段1
按字段1进行分组,查出每个组的行数。

解决方案 »

  1.   

    select count(*) as Totle, 字段1, 字段二, ....
    from table
      

  2.   

    @@ROWCOUNT
    返回受上一语句影响的行数。语法
    @@ROWCOUNT返回类型
    integer注释
    任何不返回行的语句将这一变量设置为 0 ,如 IF 语句。示例
    下面的示例执行 UPDATE 语句并用 @@ROWCOUNT 来检测是否有发生更改的行。UPDATE authors SET au_lname = 'Jones'
    WHERE au_id = '999-888-7777'
    IF @@ROWCOUNT = 0
       print 'Warning: No rows were updated'
      

  3.   

    select count(*) as 行数,字段1,字段2,....
    from table
      

  4.   

    select 字段1,字段2,....
    from tableselect @@rowcount  行数
      

  5.   

    不好意思,刚才没把意思写清楚,大家误解了我的意思:
    select 第几行,列1,列2....
    from table如有一表,a string ,b int
              abc      1
              def      3现在我用select查询结果为
    第几行,  a,     b
    1        abc    1
    2        def    3
      

  6.   

    SELECT IDENTITY(int, 1,1) AS ID,a,bfrom table
      

  7.   

    select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
    select * from #temp where ID_Num between 10 and 20
      

  8.   

    更正:
    SELECT IDENTITY(int, 1,1) AS ID,a,b
    into #t
    from table
    select * from #t
      

  9.   

    1.
    SELECT IDENTITY(int, 1,1) AS ID,a,b
    into #temptable
    from yourtablename
    2.
    select * from #temptable好象有点迟了?呵呵!