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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to force the migration to nvarchar?

Author  Topic 

brace77
Starting Member

25 Posts

Posted - 2009-07-09 : 07:57:46
Hello

I am preparing the database for the next relase of my software.

In this release I am going to drop support for SQL SERVER 2000 and to introduce unicode support. Forthis I would like to do the following:
- change all varchar fields to nvarchar fields (changing them to nvarchar(max) if varchar(n) had n > 4000)
- change all text to nvarchar(max)
- change all image to varbinary(max)

Since what i am doing is "good" I mean I cannot lose data migrating from varchar(20) to nvarchar(20) is there a trick to alter the tables without droppng all defaults / check constraints / indexes / Primary keys???

Like "alter table WITH DONTCARE" ?

For now I made a script that drops and recreates the default constraints, but i am handling manually all check constraints, indexes, primary and secondary keys.

In this way I can do it, it will take 3-4 days to accomplish but... I would like to search for an alternative approach.

Anyone can help ?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-09 : 10:20:56
you cant do this without dropping constraints,indexes,... However instead of manually searching you can use metadata views like information_schema.constraint_column_Usage to get list of constraints on table/column and then generate script for creating/dropping
Go to Top of Page
   

- Advertisement -