Problems Storing Unicode Characters With NVARCHAR

Posted: April 14, 2011 in SQL Server 2005

When trying to insert or update a SQL Server NVARCHAR column, you have to use the following syntax for unicode characters:

-- Create table variable
CREATE TABLE currency (id       INT IDENTITY (1,1),
                       country  NVARCHAR(100),
                       currency NVARCHAR(100),
                       code     NVARCHAR(100),
                       symbol   NVARCHAR(100));

INSERT INTO currency (country,currency,code,symbol) VALUES ('Azerbaijan','New Manats','AZN',N'ман');

Update Statement

UPDATE [dbo].[currency] SET symbol = N'ман' WHERE code = 'AZN';

The prefix N before the value is required to make sure the string is in Unicode format.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s