I wan t to upload the xml data to the sql table. I am passing the xml data from .net(c#)(Working fine)
code:
ALTER PROCEDURE [dbo].[BookDetails_Insert] (@xml xml)
AS
insert into BookDetails (Pages,Descriptions)
SELECT
ParamValues.PLName.value('.','int'),
ParamValues.PLDEscr.value('.','text')
FROM
@xml.nodes('/booksdetail/Pages') as ParamValues(PLName)
@xml.nodes('/booksdetail/Description') as ParamValues(PLName, PLDEscr)
xml Code:
<booksdetail>
<isbn_13>70100048</isbn_13>
<isbn_10>00048B</isbn_10>
<Image_URL>http://www.thenet.com/Book/large/00/701001048.jpg</Image_URL>
<title>QUICK AND FLUPKE</title>
<Description>QUICK AND FLUPKE </Description>
</booksdetail>
<booksdetail>...</booksdetail>
Problem: It is not doing anything on the table.
Your sample xml does not have a
Pagesnode. This means that when theFROMclause is computed, a cross join is formed between a list of zero rows and a list of one row. The resulting product has no rows, so there is nothingSELECTed, so nothing isINSERTed.If you actually want to insert one row into
BookDetailsfor eachbooksdetailnode in the incoming xml, you should do something likeThat is, shred the incoming xml into
booksdetailnodes, and pull out each of the.values you want from these rows.