Accents not getting inserted in SQL server

家住魔仙堡 提交于 2019-12-11 10:19:15

问题


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ó');

回答1:


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ó');



回答2:


Try to use N before the string while inserting like this:

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


来源:https://stackoverflow.com/questions/33391071/accents-not-getting-inserted-in-sql-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!