를 읽는 당신에게
SELECT LEFT('CHAMLY', LENGTH('CHAMLY') -1);
도움이 될 것입니다 (최대).
declare @a table([3 15] text)
insert @a values('aba;;;')
insert @a values('123abc;;')
insert @a values('abdc;')
insert @a values('abkjfshc')
insert @a values(';;;;')
;with a as
(
SELECT [3 15], cast([3 15] as varchar(max)) v
-- replace @a with your actual tablename
FROM @a
)
UPDATE a
SET [3 15] = left(v, len(v)-patindex('%;[^;]%', reverse(v) + '+') + 1)
WHERE [3 15] LIKE '%;;' -- notice the change
select * from @a
결과 :
3 15
aba;
123abc;
abdc;
abkjfshc
;
편집 :
텍스트 내에서 '%; %'의 모든 조합을 교체하려면 :
declare @a table([3 15] text)
insert @a values('aba;;;')
insert @a values('123abc;;')
insert @a values('abdc;')
insert @a values('ab;;kjf;;;;;shc')
insert @a values(';;;;')
-- if any combinations of ';;' still exists repeat until they are gone
while exists (select 1 from @a where [3 15] like '%;;%')
with a as
(
SELECT [3 15], cast([3 15] as varchar(max)) v
-- replace @a with your actual tablename
FROM @a
WHERE [3 15] LIKE '%;;%' -- notice the change
)
UPDATE a
-- to speed things up i used several replace
SET [3 15] = replace(replace(replace(replace(v, ';;;;', ';'), ';;;', ';'), ';;;', ';'), ';;', ';')
그러나 여기서 일해야 솔루션입니다
어떤 타입? – mirkobrankovic
텍스트 형식의 열입니다. – LmC
이 데이터베이스와 버전은 무엇입니까? –