# SELECT FROM OPENXML + SQL server 2005



## SAFFYWORK575 (May 9, 2006)

Hi 

I am having a problem with the way the structure of the SELECT statement should be done along with XML string being passed through the database (SQL Server 2005).

INSERT INTO TableX(ID, AddressID, AddressName)
(SELECT ID,AddressID, AddressName
FROM OPENXML(@hDoc, '/XMLDATA/ADDRESS',2) 
WITH (ID int '../@ID',AddressID int 'ADDRESSID',AddressName varchar(40) 'ADDRESSNAME')) XMLDataset 
WHERE (XMLDataset.ADDRESSTYPE = XMLDataset.DELIVERYTYPE) OR (XMLDataset.ADDRESSTYPE = XMLDataset.BOTHTYPES) 


It seems to break on the WITH line where the XMLDataset is set. I put XMLDataset as I need to use a XML node for WHERE condition.

Can you please give me an example of how that can be done by using WHERE condition within the SELECT statement to only INSERTINTO depending on the condition based on XML node.  

I will be extremely grateful for any assistance on this.

Thanks

Newbie


----------

