Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

SQL Server parse XML

The SQL below builds a test XML variable
WHat I need to do in SQL Server is loop through the nodes...
For EACH demovalue... in @XMLVar

Declare @IndividualID INT
Declare @CustomID INT
Declare @Commentsl VARCHAR (100)
SET @IndividualID = @XMLVar.....demovalues/demovalue/ind..value
Set @Comments  = @XMLVar.....demovalues/demovalue/val..value
Set @CustomID = (Select id from myDemoTable where DemoText = )
(I know I butchered that...)

And then,,,
 INSERT INTO indDemoTable (IndividualID, CustomID, Comments)
Select @IndividualID, CustomID, @Comments


DECLARE @XMLVar XML
SET @Var = '<demovalues><demovalue><ind>123456</ind><id>holder</id><val>TEST TEXT 33</val></demovalue><demovalue><ind>123457</ind><id>holder</id><val>TEST TEXT 34</val></demovalue></demovalues>'
SELECT @Var

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ste5an
ste5an
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Larry Brister

ASKER

Sorry for late response.
This was exactly what I needed