>I have an update command like this:
>
>
>UPDATE EmailTemplate SET Subject_E=CAST(REPLACE(CAST(UPPER(Subject_E) AS NVarchar(MAX)),'[OldMemberTableName]','[Member]') AS NText)
>
>
>This works but it is case sensitive.
>
>If "OldMemberTableName" is like "OLDMEMBERTABLENAME", it will not be replaced.
>
>I tried inserting UPPER( syntax in there but it never replaces it properly.
>
>How can I make such command case insensitive?
Why do you need to cast to nvarchar(max) and not varchar(max)? Are you using unicode? Also, why do you need to cast back to ntext? I don't think you need to cast back and it should work fine.
BTW, this works fine for me (e.g. both strings are replaced):
drop table #test
go
create table #test(Subject_E nvarchar(max))
insert into #test (Subject_E) values ('Testing [OldMemberTableName]'), ('Testing [OLDMEMBERTABLENAME]')
UPDATE #test SET Subject_E=replace(Subject_E ,'[OldMemberTableName]','[Member]')
select * from #test
What is the database collation and table column collation?
If it's not broken, fix it until it is.
My Blog