一字段id中的数据是这样1,3,2,5,4,等,使id中的数据重新排列1-5其他字段中数据随之变化

解决方案 »

  1.   


    --?
    order by id 
      

  2.   

    select * from tb order by Id asc
      

  3.   

    create table #(ID int)
    insert #
    select 1 union all
    select 3 union all 
    select 2 union all
    select 5 union all
    select 4
    select * from #
    /*
    ID
    -----------
    1
    3
    2
    5
    4(5 個資料列受到影響)
    */--建索引
    create index IX_# on #(ID)select * from #
    /*
    ID
    -----------
    1
    2
    3
    4
    5(5 個資料列受到影響)
    */
      

  4.   

    set nocount on
    if object_id('test')is not null drop table test
    go
    create table test (ID int ,[name] varchar(5))
    insert test select 1,'A'
    insert test select 3,'B'
    insert test select 2,'C'
    insert test select 5,'D'
    insert test select 4,'E'
    select * from test
    create clustered index Intest on test(id)
    go
    select * from test
    /*
    ID          name  
    ----------- ----- 
    1           A
    3           B
    2           C
    5           D
    4           EID          name  
    ----------- ----- 
    1           A
    2           C
    3           B
    4           E
    5           D*/
      

  5.   

    select * from tb order by id desc