创建重音字符SQL Server

Dar*_*ius 2 sql t-sql sql-server unicode

我需要更新一些包含circumflex重音的站点名称.

 update site
 set SITE_NAME = 'G?yr'
 from site
 where SITE_ID = '2112685'
Run Code Online (Sandbox Code Playgroud)

但是,站点名称更新为Gwyr,没有重音.列数据类型是nvarchar(256).我知道这^是一个UNICODE字符,所以有一个简单的解决方法可以将此字符放在更新查询中,以便在SITE_NAME列中相应地更改它.

Luk*_*zda 6

N之前添加string literal以指示它是unicode:

前缀Unicode字符串常量,字母为N.如果没有N前缀,则将字符串转换为数据库的默认代码页.此默认代码页可能无法识别某些字符.

update site
set SITE_NAME = N'G?yr'
where SITE_ID = '2112685';
Run Code Online (Sandbox Code Playgroud)

LiveDemo