Problem with parsing XML into table variable

Posted by Stanley Ross on Stack Overflow See other posts from Stack Overflow or by Stanley Ross
Published on 2010-06-07T21:09:16Z Indexed on 2010/06/07 21:22 UTC
Read the original article Hit count: 200

Filed under:
|

I'm using the following code to read a SQL XML Variable into a table variable. I am getting the following error. " Incorrect syntax near '.'. " Can't quite Figure it out

DECLARE @LOBS Table
(
LineGUID varchar(40)
)

DECLARE @lg xml
SET @lg = '<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<Table>
  <LOB>
    <LineGuid>d6e3adad-8c53-4768-91a3-745c0dae0e08</LineGuid>
  </LOB>
  <LOB>
    <LineGuid>4406db8f-0d19-47da-953b-afc1db38b124</LineGuid>
  </LOB>
</Table>'

INSERT INTO @LOBS(LineGUID) 
SELECT ParamValues.ID.value('.','VARCHAR(40)') 
FROM @lg.nodes('/Table/LOB/LineGuid') AS ParamValues(ID) 

© Stack Overflow or respective owner

Related posts about Xml

Related posts about tsql