Parent question - Thanks to Iamdave, part of the problem is solved. Now the challenge is to make the search case insensitive in the db where the following collation is set already: COLLATE Latin1_General_CS_AS
I am using this query and it is not working - couldn't match test, Test, could match only TEST
UPDATE dbo.BODYCONTENT
SET BODY = LTRIM(RTRIM(REPLACE(
REPLACE(
REPLACE(N' ' + CAST(BODY AS NVARCHAR(MAX))
+ N' ', ' ', '<>'), '>TEST<', '>Prod<'), '<>', ' ')))
FROM dbo.BODYCONTENT
WHERE BODY COLLATE Latin1_General_CI_AS LIKE '%TEST%' COLLATE Latin1_General_CI_AS;
How to make the search string in the replace function to match case insensitive
Other queries and results:
UPDATE dbo.BODYCONTENT SET BODY =
ltrim(rtrim(replace(replace(
replace(N' ' + cast(BODY as nvarchar(max)) + N' ' ,' ','<>')
,'>Test<','>Prod<),'<>',' ')))
from dbo.BODYCONTENT WHERE lower(BODY) like '%test%';
result: Argument data type ntext is invalid for argument 1 of lower function.