Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Need to select all elements of an XML document from an XML data type column Expand / Collapse
Author
Message
Posted Tuesday, September 7, 2010 4:19 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, July 20, 2014 7:29 AM
Points: 173, Visits: 340
Hi John,

I believe the output is fine from what I can tell as long as I can select all the elements from all the XML docs. Let me know if this will work based on the sample XML docs I've attached herein. In the sample docs I have selected the 1st row in the AmendBarsetFlightHistory table and displayed the XML document data that were in the columns (XMLBeforeAction and XMLAfterAction) as a reference of what I would like to select from this table. Let me know if this helps.

Thanks!

David





  Post Attachments 
XMLBeforeAction column - 1st record.docx (23 views, 19.40 KB)
XMLAfterAction column - 1st record.docx (5 views, 19.34 KB)
Post #981968
Posted Tuesday, September 7, 2010 4:43 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, July 21, 2014 1:11 PM
Points: 7,019, Visits: 12,909
@John:
Since David addressing his issues implicit to your attention ignoring other posts, I leave this thread in your hands.




Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #981976
Posted Tuesday, September 7, 2010 9:31 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, July 20, 2014 7:29 AM
Points: 173, Visits: 340
@LutzM:

The reply was actually directed to both you and John but I forgot to include your name on the posting as I was hurried to try to attach the XML docs and head out for the day to pick up my son from school. Please feel free to provide any more input and give any other suggestions as I'm really trying to get this resolved ASAP.

Thanks guys!

-David



Post #982017
Posted Wednesday, September 8, 2010 8:44 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 3:01 PM
Points: 3,843, Visits: 3,836
Lutz, I agree...please stay on. I know that you have ample XML experience and could add value to this thread. Thus far, I've been poking around to try to get an idea of what David really wants to see for output. From one of your previous posts, I think you are correct in thinking that David wants to combine the results from both colujmns (which could contain different elements).

David,

Big question here. You've shown us 1 row from your table, but I've yet to see an example of how you want your result set to look like. Based on the sample data that you've now given us, can you show us what the results should look like. Specifically, please combine the sample data that you've shown us into one result set and post that as an example of what you want your query to return. Telling us is not the same as showing us. Too much gets lost in the interpretation of the problem; whereas, a sample result set speaks for itself and we can more redily give you help.

If needed, please read the article in the link from my signature line. It talks about properly setting up sample tables/data/results to get better/faster help.




John Rowan

======================================================
======================================================
Forum Etiquette: How to post data/code on a forum to get the best help - by Jeff Moden
Post #982360
Posted Wednesday, September 8, 2010 11:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, July 20, 2014 7:29 AM
Points: 173, Visits: 340
Lutz/John,

I've sent out a communication to the developer that requested this query to see if he can explain what needs to be shown in the result set. I'm awaiting a response. In the meantime I've attached the spec they sent me to get an idea of what they're trying to retrieve in the output to present in a Crystal report.

Thanks guys!

-David





  Post Attachments 
Amend EPOS Flight Details Report Spec.xlsx (10 views, 338.80 KB)
Post #982498
Posted Friday, December 3, 2010 8:26 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, February 7, 2012 12:06 PM
Points: 1, Visits: 17
Hey! Not sure if you still care, or if this is what you are looking for, but here it is anyway :)
This assumes you know the root element name. You can store output in temp tables or table variables and process it any way you want.

DECLARE @idoc INT
DECLARE @exml XML
DECLARE @Root VARCHAR(64)

SET @Root = '/YourRootName'
SELECT @exml = [YourXMLColumn] FROM YourTable

EXEC sp_xml_preparedocument @idoc OUTPUT, @exml

select
columnNames.id,
columnNames.localname AS ELEMENT,
columnValue.text AS VALUE
FROM OPENXML (@idoc, @Root) columnNames
cross apply (select text FROM OPENXML (@idoc, @Root)
where nodetype = 3 AND parentid = columnNames.id) columnValue
where columnNames.nodetype <> 3 and columnNames.localname not in ('xsi','xsd')

Exec sp_xml_removedocument @idoc
Post #1029908
Posted Friday, December 3, 2010 9:54 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, July 20, 2014 7:29 AM
Points: 173, Visits: 340
Thanks for the reply. I used a another nasty SQL script to get the data I needed parsed from the XML docs that were stored in the table into another table so they could report on it. I appreciate your response.

I've attached the "ParseEPOSFlightDetail.txt" file for your review.

-David





  Post Attachments 
Parse_EPOSFlightDetail.txt (12 views, 8.77 KB)
Post #1030019
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse