Question

I am trying to store Arabic-strings in my database. it is working fine by using COLLATE Arabic_CI_AI_KS_WS but some of Arabic records are missing some Arabic-alphabets. i have tried with some other sollate with but result as same. how to fix it ? table structure :

CREATE TABLE [dbo].[Ayyat_Translation_Language_old_20131209] (
    [Ayat_Translation_Language_ID] INT            IDENTITY (1, 1) NOT NULL,
    [Translation_Laanguage_ID]     INT            NULL,
    [Juz_ID]                       INT            NULL,
    [Surah_ID]                     INT            NOT NULL,
    [Ayat_Description]             VARCHAR (2000) COLLATE Arabic_CI_AI_KS_WS NOT NULL
)

insertion code :

 string query = "insert into Ayyat_Translation_Language_old_20131209 values(null,null," + surah + ",N'" + verse + "')"; where verse contains Arabic contents.

and it stores data like this (with question-marks) :

?بِسْمِ اللَّهِ الرَّحْمَ?نِ الرَّحِيمِ

i have read that link : store arabic in SQL database

Was it helpful?

Solution

To store unicode string data, use NVARCHAR(2000) rather than VARCHAR(2000) for column [Ayat_Description]

Ref.: nchar and nvarchar

OTHER TIPS

All of what you have to do is to make sure that

the column Data type is nvarchar()

enter image description here

after that I inserted Arabic with no problems even with Tashkeel

enter image description here

this in SQl server management studio 2012

It may help

CREATE TABLE [dbo].[Ayyat_Translation_Language_old_20131209] (
    [Ayat_Translation_Language_ID] INT            IDENTITY (1, 1) NOT NULL,
    [Translation_Laanguage_ID]     INT            NULL,
    [Juz_ID]                       INT            NULL,
    [Surah_ID]                     INT            NOT NULL,
    [Ayat_Description]             NVARCHAR (2000) COLLATE Arabic_CI_AI_KS_WS NOT NULL

use arabic collation or use unicode(nvarchar(max))

This is a Example table For your answer :

CREATE TABLE #t11
        (

        column1 NVARCHAR(100) 

        )
        INSERT INTO #t11 VALUES(N'لا أتكلم العربية')

        SELECT * FROM #t11

fiddle demo

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top