August 8, 2011 at 8:13 am
Hi,
can i use the REPLACE function with like to accomplish this syntax?(i want to replace all non allowed keywords in file name)
declare @string nvarchar (max)
set @string = 'abc?123'
select REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(@string,'\','_'),'/','_'),':','_'),'*','_'),'?','_'),'"','_'),'<','_'),'>','_'),'|','_');
THX
August 8, 2011 at 9:14 am
I think you intend to use LIKE to find all instances that have one of the 'invalid' characters and then use the replace sequence to 'fix' the issue. Is that right?
If so, then this will probably help you: it is called pattern matching.
select <put your replace sequence here>
from <your table>
where <your column> like '%[\/:*?"<>|]%'
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply