Convert UTF 8 text to NVARCHAR in SQL Server

  • We have a Hindi language text stored with UTF-8 encoding in IBM DB2 data table. The text looks like 'सायन'. We want the Text to appear as the converted Hindi characters, instead of their ascii values, when importing it to the SQL Server NVARCHAR column.

    Had anyone done such a conversion before. Please guide.

  • I'm not sure what's the problem. SQL Server will handle unicode characters just fine.

    --Do a direct select

    SELECT N'????'

    --Using a table

    CREATE TABLE #HindiText( myString nvarchar(10));

    --Insert into...Select

    INSERT INTO #HindiText SELECT N'????';

    SELECT * FROM #HindiText;

    --Clean the table

    DELETE FROM #HindiText;

    --Insert into...Values

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

    SELECT * FROM #HindiText;

    GO

    DROP TABLE FROM #HindiText

    Unless, of course, that you mess up and generate an implicit conversion to ASCII.

    SELECT '????'

    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

Viewing 2 posts - 1 through 1 (of 1 total)

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