34,590
社区成员
发帖
与我相关
我的任务
分享
update table
set code = 'COM'+convert(char(3),substring(code,4,len(code))+2)
SELECT 'COM'+LTRIM(CONVERT(INT,(REPLACE(CODE,'COM','')))+2) AS CODE FROM TB
select distinct p2.FLOCAL_NAME,fconcentrator_no,
'COM'+ltrim(cast(replace(fdevice_code,'com','') as int)+2) as fdevice_code
from power_device,PARTNER P1,PARTNER P2,PARTNER P3,PARTNER P4
where p1.fupline=power_device.fconcentrator_no
and fdevice_code like '%COM%'
AND p1.fupline=p2.fpartner_code
AND p2.fupline=p3.fpartner_code
AND p3.fupline=p4.fpartner_code
select left(code ,patindex('%[0-9]%',code )-1)+
convert(varchar(8000),(convert(int,substring(code ,patindex('%[0-9]%',code ),8000))+2))
FROM TABLEA
select left(code ,3)+convert(varchar(8000),convert(int,right(code ,len(code )-3))+2)
FROM TABLEA
if object_id('tb') is not null
drop table tb
go
create table tb(code varchar(50))
insert into tb select 'COM50'
insert into tb select 'COM88'
insert into tb select 'COM106'
insert into tb select 'COM73'
insert into tb select 'COM27'
insert into tb select 'COM33'
insert into tb select 'COM23'
select 'COM'+ltrim(cast(replace(code,'com','') as int)+2) as code from tb