表 t1:
no              name            sex
34              qiu             m
                liu            
12                              w
                                m使之变成每行的no都有且唯一,例如
no              name            sex
01              qiu             m
02              liu            
03                              w
04                              m谢谢!

解决方案 »

  1.   

    select distinct(no) as no,name,sex from tablename order by no
      

  2.   

    angle097113(深思不解) 
    相应的sql语句怎么写?
      

  3.   

    select identity(int,1,1) as no,name,sex into #Temp from t1
    select * from #Temp
    drop table #Temp
      

  4.   

    select identity(int,1,1) as no,name,sex into #Temp from t1
    select right('00'+cast(no as varchar),2) as no,name,sex from #Temp
    drop table #Temp
      

  5.   

    你可以作一个触发器了。相应的SQL如下了。--出勤提示
    --出勤提示
    CREATE SEQUENCE T1_ID_SEQ 
      START WITH 101 
      INCREMENT BY 1 
      MAXVALUE 999999999 
      MINVALUE 101 
      NOCYCLE 
      CACHE 20 
      NOORDER
    /此处为你创建数据库的语句了。/
    CREATE TRIGGER T1_SETID BEFORE INSERT
    ON T1
    FOR EACH ROW 
    declare
    seq number;
    begin
    select T1_id_seq.nextval into seq from dual;
    :new.id:=seq;
    end;
    呵呵。这样后,在你的没创建一个新的记录后,他的ID都会自动复值了。