Friday, November 20, 2009
Home Retrieving XML Writing XML General Contact About  

How can I specify a where clause to join an OPENXML statement with a table? (12625 Requests)

Here is a small sample that you can run on the Northwind database which does what you are trying to do.


DECLARE @idoc int, @doc varchar(1000)
SET @doc ='
<ROOT>
<Employee EmployeeID="1" FirstName="Nancini"/>
</ROOT>'

EXEC sp_xml_preparedocument @idoc OUTPUT, @doc

update employees
set employees.FirstName = ox.FirstName
FROM OPENXML (@idoc, '/ROOT/Employee')
      WITH (EmployeeID  int, FirstName varchar(30)) ox
Where employees.employeeID = ox.employeeID

EXEC sp_xml_removedocument @idoc


Feedback

# Performing an update using OPENXML with a metaproperty Melissa Whalen

How can update a table that contains XML data using @mp:XMLText? (I've tried to do it already, but it only puts a blank field in where the XML should be.)

# Performing an update using OPENXML with a metaproperty Brad Smalling

I've had the same problem. INSERTing a TEXT field with @mp:xmltext works fine. The exact same UPDATE will put a blank string (not NULL) in the TEXT field and not report an error. I've tried everything I can think of--it's gotta be a bug. CHARs and VARCHARS work fine for both INSERT and UPDATE. Only TEXT and NTEXT columns fail to UPDATE properly.

# inserting or updating xml data in to SQL server 7 vijaya

we are using Sql server 7.0. Is there any way to use the xml string in stored procedure to update and insert records. I have created the xml string using xmlDOM in asp, but openxml functionality isn't available in sql 7, so I don't how to insert the data

# re: How can I specify a where clause to join an OPENXML statement with a table? CS

How can I have IF clause when retreiving data from XML using OPENXML, so that I can do something like...

IF @Name = 'TEST'

BEGIN
Do some work here...before inserting to the table....

END

Here the @Name gets the value from XML file stored in the database using OpenXML

Any help would be appreciated.

Thanks...

- webchetan

# ftmpqg frnpj qewshncdf@mail.com

tuienfo wyekv zljayqp akmngdj kcqpdfizg ohbvpm olpgrvtj

Title  
Name  
Url
Comments   


FAQ #6

last updated:
8/8/2001


Did the information in this faq help answer your question?





 
 

Survey Results: 170
Yes No N/A

© 2001, 2002, 2003 sqlxml.org