日期:2014-05-18 浏览次数:20884 次
update table1 set aa= case when left(aa,1)='Q' then 'L'+right(aa,len(aa)-1) else aa end --或者 update table1 set aa= 'L'+right(aa,len(aa)-1) where left(aa,1)='Q'
------解决方案--------------------
update table1 set aa=stuff(aa,1,1,'L') where left(aa,1)='Q'
------解决方案--------------------
update table1 set aa=stuff(aa,charindex('Q',aa),1,'L') where aa like '%Q%'
------解决方案--------------------
update table1 set aa=stuff(aa,1,1,'L') where left(aa,1)='Q'
------解决方案--------------------
if object_id('[table1]') is not null drop table [table1] create table [table1] (aa varchar(6)) insert into [table1] select 'Q1234Q' union all select 'Q4321' update table1 set aa=stuff(aa,1,1,'L') where left(aa,1)='Q' select * from [table1] /* aa ------ L1234Q L4321 */
------解决方案--------------------
create table tbl(
id varchar(20) not null,
name varchar(20) not null
)
insert into tbl values('Q0411tracy','tracy')
insert into tbl values('M0917kobe','kobe')
insert into tbl values('Q0574tom','tom')
insert into tbl values('N0755lucy','lucy')
select *from tbl
update tbl set id='L'+right(id,len(id)-1) where left(id,1)='Q'
------解决方案--------------------
用来用去就是几个函数,你们都有神了啊