Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
fmardani
Constraint Violating Yak Guru
433 Posts |
Posted - 2007-02-23 : 04:49:49
|
| Hi,Trying to use OpenXML in sql server 2000 to insert the xml data into table.As you can see in the sql code I am first trying to see if the select * works but nothing is returned. The idea is to eventually get this to do the insert into the table.can you please see what i am doing wrong?Here is the xml sample. Next you will see the SQLThanksdeclare @doc varchar (1000)declare @idoc intSET @doc = ' <marketData> <date>21-Feb-2007 11:26:39</date> <producedBy>Dominic Harris</producedBy> <isDifferential>True</isDifferential> <forwardCurves> <forwardCurve code="CU LME_FUT"> <maturities> <maturity> <contractMonth /> <date>30-Dec-1899</date> <mid>-2,400.00</mid> <bizDays>0</bizDays> </maturity> <maturity> <contractMonth /> <date>30-Dec-1899</date> <mid>-2,382.00</mid> <bizDays>0</bizDays> </maturity> <maturity> <contractMonth /> <date>30-Dec-1899</date> <mid>-2,388.00</mid> <bizDays>0</bizDays> </maturity> <maturity> <contractMonth /> <date>30-Dec-1899</date> <mid>-2,394.00</mid> <bizDays>0</bizDays> </maturity> </maturities> </forwardCurve> </forwardCurves> </marketData> '--Create an internal representation of the XML documentEXEC sp_xml_preparedocument @idoc OUTPUT, @doc--insert into tblMarketValuesselect *FROM OPENXML (@idoc, '/marketData/forwardCurves/forwardCurve/maturities/maturity',2)WITH ( contractMonth varchar(80), [date] datetime, mid decimal(10, 5), bizDays int)-- Clear the XML document from memoryEXEC sp_xml_removedocument @idoc |
|
|
|
|
|