Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

1 Posts

Posted - 12/03/2013 :  17:38:15  Show Profile  Reply with Quote
Using SQL SERVER 2008 R2:
I have a table with 35 million records, one of the field is of datatype VARCHAR(MAX), it has well formed XML stored. Now we have to convert this column to XML data type. Trying 2 possible ways
1) Creating new column with XML data type and updating that column using CAST(XMLFeildname as XML)-- taking a week to do so.
2) Just altering table to change datatype to XML, this is also taking more 1 day.

Please suggest an efficient way to do this faster.

Thanks in advance.

Almighty SQL Goddess

38200 Posts

Posted - 12/03/2013 :  17:59:28  Show Profile  Visit tkizer's Homepage  Reply with Quote
It only has 35 million rows, but I suspect that the row sizes are big.

I think I would create an additional table with the proper layout. Create a view that unions both together. Use the view in the application while you migrate the data between the two tables. Have the insert to the new table and delete from the old table be in a transaction so that the data only appears in one location. Migrate the data in small batches. Loop until done. Then ditch the view.

Tara Kizer
SQL Server MVP since 2007
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000