I have a text field that has XML in it. It is untyped and I get errors when I try to convert it from text to xml. Below is a sample of what I am trying to do
declare @x varchar(max)
set @x = '<a><b>abc</b>'
select CONVERT(xml, @x)
select CAST(@x as xml)
and I get the following error
Msg 9400, Level 16, State 1, Line 4
XML parsing: line 1, character 13, unexpected end of input
My question is, is there a way to check to see if a text field is valid XML? If not, is there a way around it easily?
Thanks!
Michael