RT

解决方案 »

  1.   

    select id=identity(int,1,1),* into newtbname from oldtbname order by 关键字
      

  2.   

    select NewID = identity(int,1,1) into NewTable from OldTable order by 旧的数据的编号按关键字排序
      

  3.   

    上面漏了 *
    select NewID = identity(int,1,1), * into NewTable from OldTable order by 旧的数据的编号按关键字排序
      

  4.   

    只是提供一个思路,并不是考试答题,你可以用临时表,清空原表,改好表结构,再Insert,并非一成不变。
      

  5.   

    ---这样????????
    /*给你一个思路
      首先给你关键字建一个有序列的索引
      然后再在你的表的增加一个自动增长列如ID,
      这样应该是可以实现你的....*/---1、
    Create Nonclustered Index Test_Index
    On 表(关键字列 Asc)
    With
    Fillfactor=50
    ---2
    Alter Table 表 Add id int identity(1,1)  
    ---3、
    Drop Index 表.Test_index 
    ---4、
    Select * From 表
      

  6.   

    用2005的排序函数 row_number()
    select row_number() over (order by id), * from sysobjects
      

  7.   

    就是先给你关键字建一个有序列的索引
    然后再在你的表的增加一个自动增长列如ID
    ------
    ---创建测试环境
    Create Table 测试ADD(Name Varchar(8),Class int)
       Insert 测试ADD Select 'ddd',1
       Union All Select 'bbb',3
       Union All Select 'ccc',2
       Union All Select 'aaa',4
    Select * From 测试ADD
    /*假设你的关键字为:Class
      你要对Class排序建自增列
    */ 
    如:
    ---1、创建索引
    Create Nonclustered Index Test_Index
    On 测试ADD(Class Asc)
    With
    Fillfactor=50
    ---2 增加id列,id列为自增列
    Alter Table 测试ADD Add id int identity(1,1)  
    ---3、删除索引
    Drop Index 测试ADD.Test_index 
    ---4、查询结果
    Select * From 测试ADD  /*注意下面结果
      自增列id 为   1 3 2 4
      并不是        1 2 3 4
      (说明它是按照Class升序自增的)
    *//*
    Name     Class       id          
    -------- ----------- ----------- 
    ddd      1           1
    bbb      3           3
    ccc      2           2
    aaa      4           4(所影响的行数为 4 行)*/
      

  8.   

    楼上正确
    补充几点:
    >1 
    Create Nonclustered Index IndexName
    On(按楼主需要可以是多个字段)
     
    >2查看时select id,按楼主需要可以是多个字段 from 表 order by 按楼主需要可以是多个字段