用于个临时表把这些符合条件的记录"COPY"过来,并增加一个序号的字段,
然后就可以Update了。
XX1  XX2   XX3
     111   111 
     123   123
     234   234     ||
    ||   
   \||/
    \/XX0   XX1  XX2  XX3
1          111   111 
2          123   123
3          234   234 
    ||
    ||   
   \||/
    \/
XX0   XX1  XX2  XX3
1     001  111   111 
2     002  123   123
3     003  234   234 笨方法,好象可以实现。

解决方案 »

  1.   

    string ls_temp
          int li_i
          declare cursor_name cursor for select column_name1(主键)
          table_name where column_name2 is null;
          if sqlca.sqlcode<>0 then
             open cursor_name;
             while sqlca.sqlcode<>0
                   li_i=1
                   fetch cursor_name into :ls_temp
                   update column_name2 set li_i='001' where 
                   column_name1=:s_temp;
                   li_i++
             do
            end if
                   
             
      

  2.   

    上一次有错误,先纠正
    string ls_temp
    int li_i
          declare cursor_name cursor for select column_name1(主键)
            from table_name where column_name2 is null;
          if sqlca.sqlcode=0 then
             open cursor_name;
             while sqlca.sqlcode=0
                   li_i=1
                   fetch cursor_name into :ls_temp
                   update column_name2 set li_i='001' where 
                   column_name1=:s_temp;
                   li_i++
             do
             close cursor_name;
            end if
      

  3.   

    不好意思,再次纠正
    string ls_temp
    int li_i
          declare cursor_name cursor for select column_name1(主键)
            from table_name where column_name2 is null;
          if sqlca.sqlcode=0 then
             open cursor_name;
             li_i=1
             while sqlca.sqlcode=0
                   
                   fetch cursor_name into :ls_temp
                   update column_name2 set li_i='001'
                   where column_name1=:s_temp;
                   li_i++
             do
             close cursor_name;
            end if
      

  4.   

    select identity(int,1,1) ,* into #tmp from yourtable where yourcolumn isnullupdate yourtable set yourcolumn=#tmp.column from #tmp where yourtable.id=#tmp.id
      

  5.   

    使用identity不好实现'001',而且根据题目,似乎不是所有的这个列所有的值都为空。
    过去数据的处理:
    select identity(int,1,1) ,* into #tmp from yourtable where yourcolumn isnullupdate yourtable set yourcolumn=right('000'+str(#tmp.column),3) from #tmp where yourtable.id=#tmp.id