INSERT Chinese characters in SQL 2008

  • I am trying to insert Chinese characters into database.

    by using below code

    have declared name as nvarchar in database and added 'N' infront. But this doesnt solve my problem of inserting chinese. Also this adds letter N infront of column Name for all records even in english.

    Can any one please advice me on this....

    CREATE PROCEDURE [dbo].[USP_WriteModifiedData]

    @Idvarchar(5000) ,

    @Namevarchar(5000),

    AS

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    INSERT INTO dbo.tblVideoData(Id,Name, modified)

    VALUES ( @Id, 'N'+@Name,@date,@modified)

  • @Name varchar(5000),

    all your variables must be nvarchar, including the procs definition and the final resulting column;

    otherwise you get an implicit converison, which changes it to quesiton marks or other characters.

    CREATE PROCEDURE [dbo].[USP_WriteModifiedData]

    @Id Nvarchar(5000) ,

    @Name Nvarchar(5000),

    AS

    BEGIN

    -- SET NOCOUNT ON added to prevent extra result sets from

    -- interfering with SELECT statements.

    SET NOCOUNT ON;

    INSERT INTO dbo.tblVideoData(Id,Name, modified)

    VALUES ( @Id,@Name,@date,@modified)

    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!

  • Hi

    You don't need the leading 'N' if you already get the data as variables. But you need to define your variables in your procudedure as NVARCHAR, like in your table.

    Greets

    Flo

  • Great!! Thanks to both of you!! It is working!!!

Viewing 4 posts - 1 through 3 (of 3 total)

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