Guidance on Unicode conversion

I'm upgrading an enterprise app database with 130 tables to support unicode. As far as I know this means turning all varchar to nvarchar, text to ntext and char to nchar.

I wrote the following script...

select
'alter table ' + b.name + ' alter column ' + a.name + ' nvarchar(' + convert(varchar(40), a.length) + ')' +
case a.isnullable when 1 then ' NULL' else ' NOT NULL' END As AlterStmt,
b.name, a.name, a.xtype, a.length, a.* from syscolumns as a inner join sysobjects as b on a.id = b.id
where a.xtype = 167
and b.type = 'U'
order by b.name, a.name

Thats giving me alter statements for every varchar field, but when I try to run it, it fails because indexes exist. There probably are also one or two char fields which form keys although 99% will be pk'd on an incremental int field

Question is: is there an easy way of getting through this without dropping all the indexes etc ? Otherwise I suppose I have to go the generate sql script route - drop the indexes, run the alter tables, and then recreate the indexes.

I am looking for the least possible impact solution since the current database is live at over 100 customer sites and I must minimise risk during upgrades



LVL 8
plqAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
The problem with your query is
1.You cant alter a Text column to ntext, you need to  create the column and populate the data for this
2. You are altering the table dtProperties'
0
plqAuthor Commented:
thanks, but my Question is at the bottom: see "Question is:" above

0
Aneesh RetnakaranDatabase AdministratorCommented:
plq,
>  is there an easy way of getting through this without dropping all the
> indexes etc ?

NO otherway You should drop and create the index
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

Aneesh RetnakaranDatabase AdministratorCommented:
there is no way to alter an index other than dropping and recreating, in sql server 2000
0
imran_fastCommented:
Depends upon the number of tables you have?
You can do this in Enterprise Manager by going into the design of the table it will automatically drop and recreate the indexes for you.
0
plqAuthor Commented:
120 tables and installed at over 100 customer sites, each one will need to be upgraded. So I'm hoping for some silver bullet thats going to allow me to achieve this reliably !! Sounds like I just need to generate sql scripts, drop the indexes, alter tables, recreate ntext, and then recreate indexes
0
imran_fastCommented:
You can create a change script for each table once and then deploy those change scripts to each client site.
When you made any change in the design mode in the enterprise manager the 3rd icon (script changes is highlighted) click on that and save it for the changes.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.