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.
Author |
Topic |
codism
Starting Member
11 Posts |
Posted - 2007-03-29 : 12:49:51
|
I need to alter a table to change a nvarchar column to varchar column. The problem is that the column already contained many data. Before altering the table, I want to know if such a conversion is safe or not for all existing data because varchar does not cover all unicode code points. |
|
snSQL
Master Smack Fu Yak Hacker
1837 Posts |
Posted - 2007-03-29 : 13:09:21
|
Run a query like this on the table and if it returns any rows then you are going to lose unicode data, or at least it will be different after converting to varchar. Assuming your nvarchar is 20 characters (change the query to match how long your nvarchar is)SELECT yourcol AS [Unicode], cast(yourcol as varchar(20)) AS [NonUnicode]FROM yourtableWHERE yourcol <> cast(yourcol as varchar(20)) |
|
|
codism
Starting Member
11 Posts |
Posted - 2007-03-29 : 14:15:22
|
Nice idea! Thanks |
|
|
|
|
|