insert arabic values to db

  • Hi All,

    i cannot insert any record that contains arabic characters to ms sql db.

    after i execute insert query, in my application all inserted values in table look like '?????? '.

    how can i solve this problem?

    INSERT INTO MY_TABLE (MY_FIELD) VALUES (' ÍÞæÞ ÇáØÈÚ')

  • Hi mollyjones,

    quote:


    i cannot insert any record that contains arabic characters to ms sql db.

    after i execute insert query, in my application all inserted values in table look like '?????? '.

    how can i solve this problem?

    INSERT INTO MY_TABLE (MY_FIELD) VALUES (' ÍÞæÞ ÇáØÈÚ')


    of what data type is MY_FIELD ?

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Hi,

    datatype is NVARCHAR(50)

    thanks in advance.

    and MSSQL SERVER collation LATIN1_GENERAL_CI_AS

    quote:


    Hi mollyjones,

    quote:


    i cannot insert any record that contains arabic characters to ms sql db.

    after i execute insert query, in my application all inserted values in table look like '?????? '.

    how can i solve this problem?

    INSERT INTO MY_TABLE (MY_FIELD) VALUES (' ÍÞæÞ ÇáØÈÚ')


    of what data type is MY_FIELD ?

    Cheers,

    Frank


  • Hi mollyjones,

    quote:


    datatype is NVARCHAR(50)

    thanks in advance.

    and MSSQL SERVER collation LATIN1_GENERAL_CI_AS


    not that I'm too familiar with arabic character, but according to BOL there is a special collation Arabic_BIN and a codepage 1256 for this.

    I might be wrong, but I don't think you can use LATIN1_GENERAL_CI_AS for this.

    Did you look up BOL for collations->concepts ?

    HTH

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Hi,

    I agree with you Frank, I don't think the Latin collation can handle the Arabic characters, number of bytes for special chars blah.

    From BOL

    quote:


    Each column in a table can be assigned different collations. Earlier versions of SQL Server support only one collation for each instance of SQL Server. All databases and database objects created in an instance of SQL Server 7.0 or earlier have the same collation.


    Lets hope you have 2000!!!

    Ritch

    *I didn't do anything it just got complicated*


    "I didn't do anything it just got complicated" - M Edwards

  • Hi

    Please do correct me if i am wrong, but i think the only effect the collation setting has on UNICODE data is on the sort order.

    Here's what BOL says...

    1. Unicode was designed to eliminate the code page conversion difficulties of the non-Unicode char, varchar, and text data types

    2. Collation still makes a difference when you implement all columns using Unicode data types because it defines the sort order for comparisons and sorts of Unicode characters

    3. Even when you store your character data using Unicode data types you should pick a collation that supports most of the users in case a column or variable is implemented using the non-Unicode data types.

    4. A SQL Server collation defines how the database engine stores and operates on character and Unicode data. After data has been moved into an application, however, character sorts and comparisons done in the application are controlled by the Windows locale selected on the computer

    Molly's problem seems to be that the Arabic characters in a UNICODE [nvarchar(50)] field are not **displayed** correctly.

    My guess is that the collation settings or windows locale info on your system, determine how you see the data. If you are acessing the DB from a system with different collation settings from the machine running the DB, that might explain what you see.

    It is true that in SQL 2000 collation can be set even at the column level. But if the field holds UNICODE data, I think collation does not affect how the data is stored - only how it is sorted.

    Check if the collation/windows locale settings of

    a. your system

    b. The app inserting data into the DB

    coincide with that of the DB

    Hope that helps...

    Correct me if i am wrong...

  • hi vivian123,

    quote:


    Please do correct me if i am wrong, but i think the only effect the collation setting has on UNICODE data is on the sort order.

    ...

    Molly's problem seems to be that the Arabic characters in a UNICODE [nvarchar(50)] field are not **displayed** correctly.

    ...

    My guess is that the collation settings or windows locale info on your system, determine how you see the data. If you are acessing the DB from a system with different collation settings from the machine running the DB, that might explain what you see.


    I don't think, you're wrong!

    I was assuming that client use appropriate settings .

    However, there is an interesting article in BOL on Mixed Collation Environments. See collations->mixed collation environments for details.

    Cheers,

    Frank

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

  • Solution :

    ----------

    1- set collation of DB to SQL_Latin1_General_CP1265_CI_AS

    2- set field type to NVARCHAR(50) (so it is unicode)

    3- if you install SQL server 2000 on NT, you will see "?????" instead of charcters ... because this NT version is english not Arabic edition.

    but i try to use Enterprise Manager on any Windows 2000.. you will see the string correctly. (windows 2000 is unicode installed)

    hope this solve your problem.

    Alamir Mohamed

    Alamir_mohamed@yahoo.com


    Alamir Mohamed
    Alamir_mohamed@yahoo.com

  • Having just looked into this issue myself, I think it should be possible. In the example you give, I think all you are missing is the N in front of the literal to indicate Unicode.

    The following code will successfully store the data correctly here (SQL 2000 on NT4) in the first three columns of the table, but not the fourth. (Note - I don't think the Arabic script will display correctly on the forum web page - you may see ???s below instead):

     
    
    create table Arabic (
    Unicode_Arabicnvarchar(50)COLLATE Arabic_CI_AI NULL,
    Unicode_Defaultnvarchar(50)COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    Varchar_Arabicvarchar(50)COLLATE Arabic_CI_AI NULL,
    Varchar_Defaultvarchar(50)COLLATE SQL_Latin1_General_CP1_CI_AS NULL
    )

    insert into arabic (
    Unicode_Arabic,
    Unicode_Default,
    Varchar_Arabic,
    Varchar_Default )
    values (
    N'ÇááÛÉ ÇáÚÑÈíÉ',
    N'ÇááÛÉ ÇáÚÑÈíÉ',
    N'ÇááÛÉ ÇáÚÑÈíÉ',
    N'ÇááÛÉ ÇáÚÑÈíÉ' )

    If you now select from this table, only the "Default_Varchar" column should come back as ???s.

    Cheers

    John

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply