Results 1 to 5 of 5

Thread: HELP: Inserting non-english(Hebrew) characters in MS SQL SERVER

  1. #1
    Join Date
    Mar 2008
    Posts
    3

    Unhappy HELP: Inserting non-english(Hebrew) characters in MS SQL SERVER

    Hi Friends,
    I am trying to insert Hebrew string into my database from my Java based tool. I am using SQL Server 2005 and the latest MS SQL jdbc driver. After i insert the string, all the Hebrew characters are in an unreadable format (some junk basically).
    My requirement is to download the rows of that particular table of the database (containing Hebrew) into an EXCEL sheet, give the corresponding english translation and upload it back. But since i am getting junk characters in the excel sheet, i am unable to translate
    I have tried changing the COLLATE parameter of the database and tables while creating the database, but still the issue persists.
    Please help me.
    Thanks in advance!

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Did you try with unicode data type?

  3. #3
    Join Date
    Mar 2008
    Posts
    3
    sorry, i didnt get you... Unicode data type?
    Its VARCHAR column with Collate defined as
    Code:
    SQL_Latin1_General_CP1255_CI_AS

  4. #4
    Join Date
    Mar 2008
    Posts
    3
    I tried defining the column name as nvarchar and now i am able to directly insert the Hebew data into the database table. So now I am sure that the issue is NOT with sql server but with my PreparedStatement.


    insert into Static_String1 values (N'עברי ת')
    The above command works fine, as I am appending N with the Hebrew string when inserting. But the problem is in my real code, I wont be able to append N with the dynamic string variable

    Here is my code piece

    sql = "insert into Static_String1 values (?)";
    PreparedStatement statement=connection.prepareStatement(sql);
    //String str = new String("\u05D0\u05D4\u05E5\u05E6\u05D7"); /* This works fine*/
    String str = statString; /*statString is the dynamic string variable containing Hebrew characters... not working*/
    statement.setString(1,str);
    statement.executeUpdate();
    statement.close();
    Please let me know how to ensure that the database recognise that an unicode string is being inserted.

  5. #5
    Join Date
    Sep 2002
    Posts
    5,938
    Unicode data type has n in type name like nchar, nvarchar and ntext.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •