MS SQL Server Parse XML

I have a @var coming in as XML

I need a function to parse the variable below so I have a data row
Name                            SalesSIteID
Grand Vacations          103405


DECLARE @var1 XML = '<Response><Name>Grand Vacations</Name><SalesSiteID>103405</SalesSiteID></Response>'
Larry Bristersr. DeveloperAsked:
Who is Participating?
 
ste5anConnect With a Mentor Senior DeveloperCommented:
E.g.

DECLARE @var1 XML = '<Response><Name>Grand Vacations</Name><SalesSiteID>103405</SalesSiteID></Response>';

SELECT	Response.value('Name[1]', 'NVARCHAR(255)') AS Name,
        Response.value('SalesSiteID[1]', 'NVARCHAR(255)') AS SalesSiteID
FROM	@var1.nodes('Response') A ( Response );

Open in new window

0
 
Larry Bristersr. DeveloperAuthor Commented:
As usual Stefan well done
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.