tsql - SQL Server 2008 Replace function with exclusions -


i have column of type nvarchar(max) in table contains substring '><'.

i need replace '><' , make '> ​ ​ ​ <', want when not '><\' or '><!'.

is there way make replace function conditional?

there several occurrences of '><' in column.

thanks help.

you can first replacing sequences want keep sequences won't naturally appear in column, replace ones want replace, switch others back.

declare @x nvarchar(max) = n'<foo><blat><!--comment--><\blat><bar>';  select @x = replace(replace(replace(replace(replace(@x,    '><!', '~~~~~!'), '></', '~~~~~\ '), -- hide ones want keep   '><', '> <'),                        -- replace ones want replace   '~~~~~!', '><!'), '~~~~~\ ', '><\'); -- un-hide ones want keep  select @x; 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -