By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,413 Members | 1,594 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,413 IT Pros & Developers. It's quick & easy.

How to insert Unicode data into table when pulling data from another table

P: 1
Hi,
I'm trying to take data from varchar fields in one table and copy it to Nvarchar fields in another table. (Long story - now dealing with multiple languages, not enough space in row in current table for multiple Nvarchar fields...).

I know how to insert new text into the Nvarchar fields:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblNotes ( noteID, note )
  2. SELECT 1, N'This is a unicode note'
but the problem I'm having is when I'm pulling the text to insert from another table:

Expand|Select|Wrap|Line Numbers
  1. INSERT INTO tblNotes ( noteID, note )
  2. SELECT tblEvents.eventID, tblEvents.eventTitle
  3. FROM tblEvents;
How do I indicate that the "eventTitle" field should be inserted as Unicode? I can't add a preceding 'N' to it as I would if directly inserting data.

Thanks for any insight.
Cathy
Aug 10 '09 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 145
Try using COLLATE in your SELECT statement.

Expand|Select|Wrap|Line Numbers
  1. SELECT myField1COLLATE [SQL_Latin1_General_CP1_CI_AS] FROM someTable 
As it turns out SQL Server 2005 uses UCS-2 encoding scheme to simulate Unicode support. So there's really no Unicode UTF-8 collation in SQL 2005. Yes, I know the universe is encoded in UTF but MS picked something obscure for its encoding...
Aug 12 '09 #2

Post your reply

Sign in to post your reply or Sign up for a free account.