SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

SQLDER
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.

tkizer
Almighty SQL Goddess

USA
36661 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
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000