• ** Update**

    I went through the example as presented and even though it worked it generated error messages (SQL 2012).

    I changed the script to what I thought it should be and the errors went away.

    Thanks for taking the time to write the article. I understand the material better than I did yesterday after reading about this topic in one of my books. 🙂

    ** End Update **

    Did you make a mistake in the openxml example? :w00t:

    I ask this because you have the following:

    EXEC sp_xml_prepareDocument @hdoc OUTPUT, @Doc

    So now I have to access the xml data using @hdoc right?

    But you do it through @idoc in the following statement.

    FROM Openxml (@iDoc,'//StockMarketData/StockData ')

    You refer the reader to a Microsoft example which is:

    EXEC sp_xml_preparedocument @idoc OUTPUT, @doc

    OPENXML (@idoc, '/ROOT/Customer',1)

    So it would seem that your openxml statement should be:

    FROM Openxml (@hdoc, '//StockMarketData/StockData' @iDoc)

    Am I correct or am I missing something because I do not understand how you can access the xml data using

    @idoc which you initialize to a value of 1? Struggling a little with this.