Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 cast as utf-8?

Author  Topic 

craigwg
Posting Yak Master

154 Posts

Posted - 2011-09-02 : 16:11:55
I know this is not possible but this shows the effect I'm going for:

select cast(columnname as utf-8) from tablename


I have some greek language I need to encode and decode, specifically in a select statement as above.

Suggestions?

Craig Greenwood

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-02 : 16:12:34
nvarchar?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

craigwg
Posting Yak Master

154 Posts

Posted - 2011-09-02 : 16:16:25
nope...data is manipulated by applications we have no control over. nvarchar won't work here, although normally it would.

Craig Greenwood
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-02 : 16:19:22
I don't understand the problem then.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

craigwg
Posting Yak Master

154 Posts

Posted - 2011-09-02 : 16:22:28
Basically...I need to change the collation of the column alone when selecting. That might be a better phrasing.

Craig Greenwood
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-02 : 16:24:51
Have you tried the COLLATE clause? BOL link: ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/tsqlref9/html/76763ac8-3e0d-4bbb-aa53-f5e7da021daa.htm

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

craigwg
Posting Yak Master

154 Posts

Posted - 2011-09-02 : 16:31:53
having a hard time loading or searching for that link. Do you ahve a normal URL for that page?

Craig Greenwood
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-09-02 : 16:36:15
I think the only option you have to be able to store UTF-8 is to use VARBINARY. But, I'm not an expert in that arena.

For Tara's edification NVARCHAR is UCS2 not UTF-8, so data loss can occur if you have actual UTF-8 encoded strings. At least, that's my understanding.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-02 : 16:36:19
http://msdn.microsoft.com/en-us/library/ms184391.aspx

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -