Darius
Darius

Reputation: 489

Create accented characters SQL Server

I need to update a few site names that contain circumflex accents.

 update site
 set SITE_NAME = 'Gŵyr'
 from site
 where SITE_ID = '2112685'

However, the site name gets updated as Gwyr, without the accent. The column data type is nvarchar(256). I know that ^ is a UNICODE character, so is there an easy fix to put this character in the update query so it gets changed accordingly in the SITE_NAME column.

Upvotes: 3

Views: 3717

Answers (1)

Lukasz Szozda
Lukasz Szozda

Reputation: 175556

Add N before string literal to indicate that it is unicode:

Prefix Unicode character string constants with the letter N. Without the N prefix, the string is converted to the default code page of the database. This default code page may not recognize certain characters.

update site
set SITE_NAME = N'Gŵyr'
where SITE_ID = '2112685';

LiveDemo

Upvotes: 7

Related Questions