表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
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
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%'
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
set @i=0
update icmo set fnote='No'+ltrim(1000000+@i),@i=@i+1
where cast(finterid as int) between 1 and 40000
set @i=0
update icmo set fnote='No'+ltrim(1000000+@i),@i=@i+1
where cast(finterid as int) between 1 and 40000
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%'
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