tags:

views:

44

answers:

1

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) 
A: 

Are you intending to use a SELECT INTO statement?

SELECT ParamValues.ID.value('.','VARCHAR(40)')
INTO @LOBS(LineGUID)
FROM @lg.nodes('...') AS ParamValues(ID)

Something like that?

Jaymz
Yes that's what I'm trying to do
Stanley Ross
change the SELECT Statement to Read SELECT ParamValues.ID.value('.','VARCHAR(40)') INTO @LOBS(LineGUID) FROM @lg.nodes('Table/LOB/LineGuid') AS ParamValues(ID) Now getting the error "Incorrect syntax near '@LOBS'"
Stanley Ross
Sorry, try getting rid of the column specification: ...INTO @LOBS FROM @lg...
Jaymz