日期:2014-05-18 浏览次数:20490 次
--> 测试数据:[test]
if object_id('[test]') is not null
drop table [test]
create table [test]([PRD_NO] varchar(4))
insert [test]
select 'abc' union all
select 'abcR' union all
select 'cde' union all
select 'cdeR' union all
select 'tyt' union all
select 'tytR' union all
select 'gfh' union all
select 'fgg' union all
select 'def' union all
select 'defR'
update test
set [PRD_NO]=[PRD_NO]+'R'
where exists(select 1 from test b where test.PRD_NO=left(b.PRD_NO,LEN(b.PRD_NO)-1))
select * from test
/*
PRD_NO
-----------
abcR
abcR
cdeR
cdeR
tytR
tytR
gfh
fgg
defR
defR
*/
--你看看这个结果对不?