Saving Hebrew text as nvarchar

  • Is there something special I need to do to be able to save some Hebrew text in my table?    I have the column set as nvarchar(max) yet when i do something like this

    Hebrew_Query

     

    It returns

    ScriptIDLanguageIDSectionIDScriptText
    671113?????? ??? ?? ??????, ???? ???
  • your query did not appear, but i suspect it has to do with implicit conversions.

    you have to use the N'' denotation to make sure SQL knows it is nvarchar data.

     

    here is a very simple example; the first returns question marks, the second the expected characters.

    SELECT '??????','??' --SELECT Database,AnimalName in Japanese
    SELECT N'??????',N'??' --SELECT Database,AnimalName in Japanese

     

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • ok the forum converts to varchar as  well! so my  nvarchar string characters got converted to question marks!

     

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • mjohnson 71479 wrote:

    Is there something special I need to do to be able to save some Hebrew text in my table?    I have the column set as nvarchar(max) yet when i do something like this

    Hebrew_Query

    It returns

    ScriptIDLanguageIDSectionIDScriptText
    671113?????? ??? ?? ??????, ???? ???

    It might be a diplay issue, or maybe you're not saving it correctly. I can't say because you added your query as an image that can't be seen instead of copying and pasting the code.

    Here's an example that worked correctly.

    CREATE TABLE #SampleData(
    SomeText NVARCHAR(MAX));

    INSERT INTO #SampleData
    VALUES( N'??? ??????? ?????');

    SELECT * FROM #SampleData;

    DROP TABLE #SampleData;

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Thank you.  I saw that it changed it to varchar and edited my original post to be an image of my query

  • Now I see the problem and the reason behind the image that I can see now.

    Here's the image of the example.

    hebrew query

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Do I need to make any changes when it is saved via SPROC?

    Here is the Current SPROC

    ALTER PROCEDURE [dbo].[AddButtons]

    @LanguageID int,
    @ButtonText nvarchar(200),
    @ButtonID int

    AS

    SET NOCOUNT ON

    IF EXISTS (SELECT ButtonText FROM dbo.Buttons WHERE LanguageID = @LanguageID AND ButtonID = @ButtonID)
    BEGIN
    UPDATE
    dbo.Buttons
    SET
    ButtonText = @ButtonText
    WHERE
    LanguageID = @LanguageID
    AND ButtonID = @ButtonID
    END
    ELSE
    BEGIN
    INSERT
    dbo.Buttons
    VALUES
    (
    @LanguageID,
    @ButtonText,
    @ButtonID
    )
    END

    I ask because I was using ADO.NET  cmd.Parameters.AddWithValue  method without first defining the SqlDbType and it saved as varchar   i.e. the question marks

    Once I changed the code to use the add method and then defined as SqlDbType.NVarChar it worked.

     

     

  • Here's an article addressing your problem when using AddWithValue.

    https://blogs.msmvps.com/jcoehoorn/blog/2014/05/12/can-we-stop-using-addwithvalue-already/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Thank you Luis!     I must not be wording my Google Queries properly because after I did a few searches I could not find anything on that that provided a lick of information to me.

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

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