qinformation
asked on
How do I replace a unicode character in an ntext field on MS-SQL
My users are pasting in text from MS-Word that includes a unicode chracter: ff (64256)
The field is ntext with collation set to: SQL_Latin1_General_CP1_CI_ AS
I cannot even determine which rows contain the character I want to replace
Neither of these statements work:
I'm hoping that once I am informed enough on how to find the rows I'm after, I can user that knowledge to write a statement to replace this character with two actual f's rather than this character.
The field is ntext with collation set to: SQL_Latin1_General_CP1_CI_
I cannot even determine which rows contain the character I want to replace
Neither of these statements work:
SELECT * FROM mytable where comment LIKE NCHAR(64256)
SELECT * FROM mytable where comment LIKE N'%' + N'ff' + N'%'
I'm hoping that once I am informed enough on how to find the rows I'm after, I can user that knowledge to write a statement to replace this character with two actual f's rather than this character.
ASKER
Pawan: Neither of those statements seem to return the right result set.
Sorry what are you searching ?
If you are searching string starts with ff then we have to use below -
SELECT * FROM mytable where comment LIKE N'ff%'
SELECT * FROM mytable where comment LIKE N'ff%'
This should work:
SELECT *
FROM mytable
WHERE comment LIKE N'%' + NCHAR(64256) + N'%';
ASKER
The result here returns both rows but should only return the one with the unicode character:
CREATE table #temp (testcolumn ntext)
insert INTO #temp SELECT N'ff'
insert INTO #temp SELECT 'ff'
SELECT * FROM #temp where testcolumn LIKE '%' + N'ff' + '%'
ASKER
Thanks ste5an. Your suggestion returns double f's. See my #temp table example for reference
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Many Thanks!
ASKER
appreciate the help all!
SELECT * FROM mytable where comment LIKE N'%' AND comment LIKE N'ff' AND comment LIKE N'%'
or this
SELECT * FROM mytable where comment LIKE N'%' OR comment LIKE N'ff' OR comment LIKE N'%'