Tuesday, February 14, 2012

Converting text data to ntext data

Hi all,

My organization have a web-based application and needs it to support multilingual so we will be adapting our app to use unicode. However, one of our problems is to convert existing data from text to ntext. I couldn't find anything that document this. What is the best way to do that? I would like to be able to migrate the data from an existing text column to another ntext column in the table.

I brief you about my system, I used List manager system to store the messages and distribute to all members. Right now,by design the Lyris system keep the message in the text field which mean it 's not support multilanguage directly because of unicode field. We needs to create new Db which has the data structure as same as Lyris but just one difference is keep the message in unicode format (ntext) which we need the sql script to automatically update the new record get from Lyris to new DB.

If I can't do that, what are the options? If it's possible, I would like to be able to do this in sql script.

Thanks a mil, in advance.

Eddie

Moving to engine folder.|||

You should be able to accomplish this by using a command similar to the following:

ALTER TABLE table_name ALTER COLUMN column_name ntext

go

After that you should run DBCC CLEANTABLE command to reclaim space occupied by old column. Also you space requirement for the altered column will double (just plan for that).

Alternatively, you can bulk copy your data out, modify the table definition, truncate the table and bulk copy data back in.

HTH,

Boris.

No comments:

Post a Comment