本帖最后由 yanjian1984 于 2010-07-30 21:24:00 编辑

解决方案 »

  1.   

    数据库版本SQL 2000,主键应该不用理的
      

  2.   

    表icmo内,有Fnote,finterID,fbillno列表内finterID值在000001至40000区间,fnote为空,fbillno为任意编号,一部分包含了%ww%字符更新finterID在21049至40000区间并且fbillno不包含’WW’的行的fnote值要求fnote值是从NO1000001开始,按照finterID从小到大递增的格式declare @i int
    set @i=0
    update icmo set fnote='No'+ltrim(1000000+@i),@i=@i+1
     where cast(finterid as int) between 1 and 40000
      

  3.   

    declare @i int
    set @i=0
    update icmo set fnote='No'+ltrim(1000000+@i),@i=@i+1
     where cast(finterid as int) between 1 and 40000
      

  4.   

    UPDATE A SET 
    fnote='NO1'+RIGHT('000000'+
    LTRIM(SELECT COUNT(1) 
               FROM icmo WHERE finterID BETWEEN 21049 and 40000 
                         and fbillno not like '%ww%' and finterID<=a.finterID ),6) 
    from icmo  a WHERE finterID BETWEEN 21049 and 40000 and fbillno not like '%ww%'
      

  5.   


    declare @num int
    set @num = 1
    update icmo
    set fnote='No'+ltrim(1000000+@i),@i=@i+1
    from icmo
    where finterID between 21049 and 40000 
    and fbillno not like '%WW%' 
    order by finterID
      

  6.   

    6楼命令有错误,update时不能使用order by