how to insert japanese characters from storedprocedure

  • Hi

    i am trying to insert japanese characters ,if i do like below it's working

    1.insert into japanese (a,b) values (1,N'C川崎市幸区');

    above one is working fine.

    But I need to insert the same from storedprocedure. so i modified procedure like below.even then it's showing C????? only with below code too.

    2.declare @msg nvarchar(max)

    set @msg= 'C川崎市幸区'

    DECLARE @SQLString nvarchar(500);

    SET @SQLString =

    N'insert into japanese (a,b)values(1,@msg)'

    exec sp_executesql @SQLString ,N'@msg nvarchar(max)',

    @msg=@msg;

    can anyone help me how can i fix this issue ?

  • Just done a quick test and I think you may be having the problem because of the collation of the database you are writing to. I set up a database with Japanese collation and then the table use the default collation as Japanese.

    CREATE TABLE [dbo].[Japanese](

    [a] [int] NULL,

    [nvarchar](500) COLLATE Japanese_Unicode_CS_AS NULL

    ) ON [PRIMARY]

    Then the code worked as expected.

    Facts are stubborn things, but statistics are more pliable - Mark Twain
    Carolyn
    SQLServerSpecialists[/url]

  • Richard,

    Thanks for reply. But our application is global,so it need to support all characters (French,Japanese,Germany,Norwegian). if i change collation will it support all characters.

  • If this is just a table for Japanese data, then just alter the collation of the field.

    ALTER TABLE [Japanese] ALTER COLUMN b NVARCHAR(500) COLLATE Japanese_Unicode_CS_AS NULL

    If the field is to hold more than Japanese you'll need to find a collation that accomodates all the languages you require.

    Facts are stubborn things, but statistics are more pliable - Mark Twain
    Carolyn
    SQLServerSpecialists[/url]

  • First, I think SQL will handle it, but you should preface your string literal with N for unicode strings. Maybe that'll help?

    set @msg= N'C?????'

    Secondly, is the display of "C?????" showing in Management Studio? I'm sorry I can't give you specific details, but I think you might have to install a font or change a setting in order to get the correct display in Management Studio. Also, you can verify if it is just a display issue by checking the ASCII values in the each of the two strings.

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

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