0

I need to update a varchar column with Arabic names in SQL.

My table column ArabicCode is of type varchar. I don't want to change the type of the column. Is there another way to update the column with Arabic names. Now it's updating as ???.

update myTable set  ArabicCode = `اسقف مستعار` where masterid = 2        

Thanks!!!

Pranav Bilurkar
  • 955
  • 1
  • 9
  • 26
  • No you can't do that with varchar datatype itself. – knkarthick24 Nov 25 '15 at 09:15
  • 6
    You need to use `nvarchar` – rcs Nov 25 '15 at 09:18
  • ok.Thank you.No other way ,are you sure?Anything related with collation? –  Nov 25 '15 at 09:23
  • 2
    Yes, you can use some arabic collation (if there is one!). However, it's very tricky - you need to make sure all your literal strings and parameters are in the proper collation, and it still means that your column has to have that collation (that is, you can't have two different collations in one column). `nvarchar` is just *much* simpler (make sure to use `N'ala'` literals rather than `'ala'`). – Luaan Nov 25 '15 at 09:26
  • It's not quite a duplicate because you have specifically asked about VARCHAR, but [this answer](http://stackoverflow.com/a/3561385/1048425) should help. Either way you are going to need to alter your column. – GarethD Nov 25 '15 at 09:50

1 Answers1

2

To achieve this you need to change the datatype from varchar to nvarchar

If you execute your update SQL query the data will be inserted as ?????? as the column type is varchar which does not allow to store any Unicode data.

Also make changes in your Update query as shown below -

update myTable set  ArabicCode = N`اسقف مستعار` where masterid = 2

To know difference check link- varchar vs nvarchar

I suggest you to change your datatype to Nvarchar

Community
  • 1
  • 1
Pranav Bilurkar
  • 955
  • 1
  • 9
  • 26
  • Ok.Thanks for the quick response.But I cant change the type of the column , I'm getting error The index '_dta_index_mr001_17_1977058079__K9_K1_K8_3_5' is dependent on column 'code'.ALTER TABLE ALTER COLUMN code failed because one or more objects access this column. –  Nov 25 '15 at 14:44