Click here to Skip to main content
15,890,282 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
In a column(name :hadith_eng_book) I have unicode and English Text.
Accidentally unicode text have copied to Column(hadith_eng_book).

Now I want to replace all unicode text with english text.
look at here
hadith_eng_book column
values are
Sunan Ibn Majah
Sunan Ibn Majah
Sunan Ibn Majah
Sunan Ibn Majah
سنن ابن ماجہ this is unicode i dont want, I want Sunan Ibn Majah text here like above
سنن ابن ماجہ
سنن ابن ماجہ

question is simple
I use this query but when I execute it. show me 0 rows effected

SQL
update [SSDB].[dbo].[Hadiths_old]
 set hadith_eng_book ='Sunan Ibn Majah'
 where hadith_eng_book= 'سنن ابن ماجہ';

i want to replace سنن ابن ماجہ with Sunan Ibn Majah.

now how to update ?
Posted
Updated 30-Sep-13 22:04pm
v2
Comments
Maciej Los 1-Oct-13 3:58am    
Maybe question is simple, but completely not understandable ;(
Muhamad Faizan Khan 1-Oct-13 4:01am    
question have improved
Azee 1-Oct-13 4:21am    
Hey Faizan, what is the datatype of hadith_eng_book Column in your table?
Muhamad Faizan Khan 1-Oct-13 11:57am    
hadith_eng_book datatype is nvarchar(50)

First of all, please, read my comment to the question.

Try to use:
SQL
DECLARE @NewText NVARCHAR(30)
SET @NewText= N'Sunan Ibn Majah'

DECLARE @OldText NVARCHAR(30)
SET @OldText = N'سنن ابن ماجہ'

update [SSDB].[dbo].[Hadiths_old]
 set hadith_eng_book =@NewText
 where hadith_eng_book= @OldText


MSDN TechNet wrote:
Many code examples prefix Unicode character string constants with the letter N. Without the N prefix, the string is converted to the default code page of the database. This default code page may not recognize certain characters.


For furhter information, please see: Transact-SQL Syntax Conventions (Transact-SQL)[^]
 
Share this answer
 
v2
Comments
Muhamad Faizan Khan 1-Oct-13 4:12am    
zero row effected executed the query with n
Maciej Los 1-Oct-13 5:28am    
See updated answer ;)
Muhamad Faizan Khan 1-Oct-13 11:59am    
really sorry Zero Row affected
you should use a simple programm to update it from out of sql

first proccess string and convert it to good format then write or update to file or sql
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900