472,119 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

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

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
1 4813
Jerry Winston
145 Expert 100+
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.

Similar topics

20 posts views Thread by akej via SQLMonster.com | last post: by
6 posts views Thread by pk | last post: by
16 posts views Thread by robert | last post: by
4 posts views Thread by Michel Esber | last post: by
6 posts views Thread by rn5a | last post: by
1 post views Thread by erikcw | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.