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

Reading from XML does not work Expand / Collapse
Author
Message
Posted Thursday, April 30, 2009 5:45 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:39 PM
Points: 7,038, Visits: 12,951
kavitus (4/30/2009)
Any good resources of starting with XQuery


I found the following article very helpful:
http://www.simple-talk.com/sql/t-sql-programming/xml-jumpstart-workbench/

@Flo:
The "quote-trick" works on my FireFox-Version, too...




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 #707592
Posted Thursday, April 30, 2009 5:51 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Sunday, November 4, 2012 12:23 PM
Points: 2,087, Visits: 3,932
kavitus (4/30/2009)
Any good resources of starting with XQuery


There are some good example in BOL.

Here a little sample for your XML. Do not copy the rendered code! It is damaged by the render engine of this forum... Use the "Quote" button for this post and copy the source from there.

DECLARE @strXML NVARCHAR(MAX)

SELECT @strXML = N'<RECORD>
<DEPTID id="10">
<Employee Name="Test101" Salary="1000"/>
<Employee Name="Test102" Salary="1000"/>
</DEPTID>
<DEPTID id="11">
<Employee Name="Test111" Salary="1000"/>
<Employee Name="Test112" Salary="1000"/>
<Employee Name="Test113" Salary="1000"/>
<Employee Name="Test114" Salary="1000"/>
</DEPTID>
</RECORD>'

Declare @xmlDat xml

SELECT @xmlDat = @strXML

SELECT
T.C.value('../@id', 'int') DeptId,
T.C.value('@Name', 'varchar(30)') Name,
T.C.value('@Salary', 'int') Salary
FROM @xmlDat.nodes('RECORD/DEPTID/Employee') T(C)

Greets
Flo



The more I learn, the more I know what I do not know
Blog: Things about Software Architecture, .NET development and T-SQL

How to Post Data/Code to get the best Help How to Post Performance Problems
Post #707598
Posted Thursday, April 30, 2009 5:54 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Sunday, November 4, 2012 12:23 PM
Points: 2,087, Visits: 3,932
lmu92 (4/30/2009)
@Flo:
The "quote-trick" works on my FireFox-Version, too...


Just kidding . The quote-trick works on every browser. The problem is not the browser but the java-script client-side render engine...

Sorry
Flo



The more I learn, the more I know what I do not know
Blog: Things about Software Architecture, .NET development and T-SQL

How to Post Data/Code to get the best Help How to Post Performance Problems
Post #707600
Posted Friday, May 1, 2009 2:40 PM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: Thursday, June 5, 2014 10:54 AM
Points: 9,902, Visits: 9,480
To make your XML show up, you need to qoute it with [ code="xml"]...[/code] tags, instead of '...'. Like this:

kavitus (4/30/2009)

<RECORD><DEPTID = "10"><Employee Name = "Test101" Salary = "1000" /><Employee Name ="Test102" Salary = "1000" /></DEPTID><DEPTID="11"><Employee Name ="Test111" Salary = "1000" /><Employee Name ="Test112" Salary = "1000" /><Employee Name ="Test113" Salary = "1000" /><Employee Name ="Test114" Salary = "1000" /></DEPTID></RECORD>



Click the QUOTE button on my post to see how I did this.


-- RBarryYoung, (302)375-0451 blog: MovingSQL.com, Twitter: @RBarryYoung
Proactive Performance Solutions, Inc.
"Performance is our middle name."
Post #708776
Posted Tuesday, May 5, 2009 5:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 8, 2010 9:26 AM
Points: 8, Visits: 13
Thanks guys. I guess the problem was with the XML not being valid.
Post #710058
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse