Search code examples
sqlsql-servercharacter-encodingnvarcharnon-ascii-characters

Accents not getting inserted in SQL server


I am trying to add this name -> NumāTwó into a table in MS sql server along with the accents. But it is only getting inserted as -> NumaTwó (without ā). I tried many encodings but doesn't seem to work. I have given the DDL of the table below. Please help

CREATE TABLE [dbo].[test](
    [testname] [nvarchar](40) COLLATE SQL_Latin1_General_CP1253_CI_AI NULL
 ) ON [PRIMARY]

----------- Insert-----------
insert into test values ('NumāTwó');

Solution

  • use N as Prefix for Unicode character

    CREATE TABLE [dbo].[test](
        [testname] [nvarchar](40) COLLATE SQL_Latin1_General_CP1253_CI_AI NULL
     ) ON [PRIMARY]
    
    ----------- Insert-----------
    insert into test values (N'NumāTwó');