How do I convert non-unicode tables to unicode tables?
Q: I have SQL Server 2005. I have to convert all the varchar Datatypes in all tables to nvarchar. (In short I have to convert the non unicode tables to unicode tables) Please let me know the code of how to do it.
Patrick O’Keeffe says: Do the tables have data in them? If not a simple script out of all the tables followed by a search and replace will do the trick.
If the tables have data you will have to write a script to:
1. drop any constraints
2. create a new table with the new nvarchar column
3. add the constraints you just dropped to the new table
4. copy the data from the old table to the new table
5. drop the old table
6. rename the new table to the old table name
7. add any indexes as appropriate
SQL Server Management Studio can generate a table change script from the table designer to study as an example.
Technorati Tags:
SQL Server 2005, unicode, non-unicode, datatypes, datatype conversions
Tags: Programming