Once, in a similar situation, I added an XML column to the same table as the Text column. Then I used the RBAR process to try to copy the “XML” from the text column to the new XML column (not the fastest, but it will make single entries and it will be one-time, right?). It is assumed that your table has a PK data type int.
declare @minid int, @maxid int;
select @minid=min(ID), @maxid=max(ID) from XMLTable;
while @minid <= @maxid
begin
begin try
update t
set XMLColumn = cast(TextColumn as XML)
from XMLTable t
where ID = @minid;
set @minid = @minid+1
end try
begin catch
print('XML transform failed on record ID:'+cast(@minid as varchar))
--advance to the next record
set @minid = @minid+1
end catch
end
source
share