pedrodenim
New Member
This seemed like a great idea on Friday afternoon but I'm having a bit of trouble. I've not used SQL XML querying before so I may of just done something incredibly stupid. Basically I want to pass a series of strings to query a table into a Stored Procedure. I thought about this for a bit, considered using a CSV and then decided to attempt to do this using XML. So My XML looks like:\[code\]<Root> <string>value</string> <string>value</string> <string>value</string> <string>value</string></Root>\[/code\]I'm passing this into a stored proc as an XML value type:\[code\]CREATE PROCEDURE usp_UpdateHotelImages -- Add the parameters for the stored procedure here @hotelID int, @imageIDs xmlASBEGIN\[/code\]so I want to shred the XML into a table of strings.My SQL looks like this:\[code\]SELECT Child.value('(string)[1]', 'varchar(200)')FROM @imageIDs.nodes('/Root/') AS N(Child))\[/code\]But I keep getting the error message \[code\]XQuery [nodes()]: Syntax error near '<eof>', expected a "node test".\[/code\] I may well be doing something incredibly stupid here so any help will be gratefully received.UpdateI've broken it down into a single query to help:\[code\]DECLARE @imageIDs xmlSET @imageIDs = '<Root> <string>value</string> <string>value</string> <string>value</string> <string>value</string></Root>'SELECT Child.value('(string)[1]', 'varchar(200)') FROM @imageIDs.nodes('/Root/') AS N(Child)\[/code\]