I have an XML stored in the SQL as image type. What I'm trying to and actually managed to accomplish is to get a data from that stored xml. The problem is the data is stored as unicode, but what I'm getting is an ascii type of the data. I've tried alot but can't make this work.
DECLARE @xml XML;
set @xml = convert(xml,(CONVERT(varchar(max), @data)));
SELECT
T.c.query('data(node1/id)') as 'id',
T.c.value('node1[1]/name[1]','nvarchar(100)') as 'name'
FROM @xml.nodes('Test1/Test2') T(c)
I'm converting data to varchar(max) because I can't get any data when I cast it into nvarchar(max). Like, if I change my code to
set @xml = convert(xml,(CONVERT(nvarchar(max), @data)));
I can't see any data.
Thanks for the help.