0

I want to save a JSON object in my column in a table. The JSON object has some Arabic text as well, which is appearing as ???? in my column.

update TableName set ArColumn='{


  "stockNameEn":"ABC",
   "formulaValues":[
      {
         "graphfield":"الحد الأدنى",
         "Minimum":"17.96"
      },
      {
         "graphfield":"الوسيط",
         "Median":"62.18"
      },
      {
         "graphfield":"بما في ذلك تأثير النمو",
         "IncludingGrowthEffect":"62.18"
      },
      {
         "graphfield":"السعر الحالي",
         "CurrentPrice":"93.10"
      },
      {
         "graphfield":"إلى الأمام",
         "Forward":"79.65"
      }
   ],
   "classification":{
      "value":1,
      "label":"Growth"
   }
}' where ID=43

I have found some solutions like to put N behind the Arabic text, but is this possible without it?

Thom A
  • 88,727
  • 11
  • 45
  • 75
Faizan Naeem
  • 433
  • 4
  • 13
  • 3
    Use an `nvarchar` not a `varchar`. Why do you not want to use an `nvarchar`? The only other way you could achieve this would be to ensure you are using a UTF-8 collated database; I wouldn't say that's the solution here. – Thom A Aug 18 '22 at 07:36
  • Does this answer your question? [What is the meaning of the prefix N in T-SQL statements and when should I use it?](https://stackoverflow.com/questions/10025032/what-is-the-meaning-of-the-prefix-n-in-t-sql-statements-and-when-should-i-use-it) – Thom A Aug 18 '22 at 07:38
  • Does this answer your question? [store arabic in SQL database](https://stackoverflow.com/questions/3560173/store-arabic-in-sql-database) – Thom A Aug 18 '22 at 07:40
  • 2
    It is not possible without the `N`. The `N` is to let your database know that the string has characters from National language character set. Otherwise the database will use the default code page. Interesting read here: [nchar and nvarchar (Transact-SQL)](https://learn.microsoft.com/en-us/sql/t-sql/data-types/nchar-and-nvarchar-transact-sql?view=sql-server-ver16) – orBeat Aug 18 '22 at 07:40
  • I hope you are not injecting data into your queries. You should parameterize them if they are coming from a client app, and then you just specify that it's a `nvarchar` parameter – Charlieface Aug 18 '22 at 10:23

0 Answers0