Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 701
Darius Avatar asked Jul 14 '26 20:07

Darius


1 Answers

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

like image 196
Lukasz Szozda Avatar answered Jul 17 '26 14:07

Lukasz Szozda



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!