Figure 5-4 Using the Value method to pull a single value in Visual Studio .NET

Creating QR Code ISO/IEC18004 in Visual Studio .NET Figure 5-4 Using the Value method to pull a single value

Figure 5-4 Using the Value method to pull a single value
QR Code JIS X 0510 Maker In VS .NET
Using Barcode maker for Reporting Service Control to generate, create QR-Code image in Reporting Service applications.
Printing Bar Code In Visual Studio .NET
Using Barcode encoder for Reporting Service Control to generate, create bar code image in Reporting Service applications.
DECLARE @myXML xml SET @myXML = '<Root> <Project ProjectNumber="101" ProjectName = "Employee Database" StartDate ="2008-06-30Z" EndDate = "2008-07-29Z" Manager = "Darril Gibson"> </Project> <Project ProjectNumber="102" ProjectName = "Build Parts Database" StartDate ="2008-08-30Z" EndDate = "2008-09-29Z" Manager = "Justin Case"> </Project> </Root>' DECLARE @ProjName varchar(50) SET @ProjName = @myXMLvalue('(/Root/Project/@ProjectName)[2]', 'nvarchar(50)' ) SELECT @ProjName AS [Project Name]
QR Code Creation In Visual C#.NET
Using Barcode maker for VS .NET Control to generate, create QR-Code image in .NET applications.
QR Code Generation In VS .NET
Using Barcode creation for ASP.NET Control to generate, create QR Code JIS X 0510 image in ASP.NET applications.
Query
Print QR Code 2d Barcode In .NET Framework
Using Barcode encoder for VS .NET Control to generate, create QR-Code image in .NET framework applications.
Paint QR Code JIS X 0510 In Visual Basic .NET
Using Barcode printer for .NET framework Control to generate, create QR Code ISO/IEC18004 image in Visual Studio .NET applications.
The Query method can be used to pull XML data from an XML column, as we did in earlier examples The Query method frequently uses XQuery language expressions that are similar to SELECT statements As with XML in general, XQuery expressions have a lot of depth, allowing you to do exactly what you want to do, even if it does take some time to create the query In the Nodes section, we ll show an example combining the Value and Query methods to pull multiple values out of an XML document We saw a simple example of the query method in Exercise 53
Paint UPC-A Supplement 5 In VS .NET
Using Barcode generation for Reporting Service Control to generate, create UPC Code image in Reporting Service applications.
Painting USS Code 39 In VS .NET
Using Barcode creator for Reporting Service Control to generate, create Code 3/9 image in Reporting Service applications.
USE XMLTest; GO SELECT ProjectDataquery('project/projectname') FROM Project Where ProjectID=2
Encode Bar Code In .NET
Using Barcode maker for Reporting Service Control to generate, create barcode image in Reporting Service applications.
Paint EAN13 In .NET Framework
Using Barcode maker for Reporting Service Control to generate, create European Article Number 13 image in Reporting Service applications.
MCITP SQL Server 2005 Database Developer All-in-One Exam Guide
Create UCC-128 In .NET
Using Barcode maker for Reporting Service Control to generate, create EAN 128 image in Reporting Service applications.
ANSI/AIM Code 128 Printer In .NET Framework
Using Barcode encoder for Reporting Service Control to generate, create USS Code 128 image in Reporting Service applications.
The result is shown in Figure 5-5
Painting Delivery Point Barcode (DPBC) In .NET Framework
Using Barcode encoder for Reporting Service Control to generate, create USPS POSTNET Barcode image in Reporting Service applications.
Bar Code Recognizer In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
Figure 5-5 The result of a query using the Query method
Drawing Matrix 2D Barcode In VB.NET
Using Barcode drawer for .NET Control to generate, create 2D Barcode image in .NET applications.
EAN 13 Generation In Java
Using Barcode creation for Java Control to generate, create European Article Number 13 image in Java applications.
Another example of the Query method is shown in the Nodes section
Encode Code 39 In Objective-C
Using Barcode maker for iPhone Control to generate, create ANSI/AIM Code 39 image in iPhone applications.
Barcode Generator In VB.NET
Using Barcode creation for .NET framework Control to generate, create barcode image in VS .NET applications.
Nodes
ANSI/AIM Code 39 Scanner In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
Scanning ECC200 In Java
Using Barcode decoder for Java Control to read, scan read, scan image in Java applications.
The Nodes method is used to shred an XML column into relational data In other words, if you have an XML column filled with data, you can use the Nodes method to pull out the data and present that data in a meaningful way The general syntax of the Nodes method is:
Nodes (XQuery) as Table(Column)
However, before we can use the Nodes method, typically we re going to pull some data out of an XML document using the Value or Query method The following query shows how we can use the Nodes method It starts by creating an XML document and then uses a SELECT statement to pull the data from the XML document
DECLARE @myXML xml SET @myXML = '<Root> <Project ProjectNumber="101"> <ProjectName>Employee Database</ProjectName> <StartDate>2008-06-30Z</StartDate> <EndDate>2008-07-29Z</EndDate> <Manager>Darril Gibson</Manager> </Project> <Project ProjectNumber="102"> <ProjectName>Build Parts Database</ProjectName> <StartDate>2008-08-30Z</StartDate> <EndDate>2008-09-29Z</EndDate> <Manager>Justin Case</Manager> </Project> </Root>' SELECT MyTablecolsvalue('@ProjectNumber', 'int') AS ProjectNumber, MyTablecolsquery('StartDate') AS StartDate, MyTablecolsquery('EndDate') AS EndDate FROM @myXMLnodes('/Root/Project') MyTable (cols)
5: XML
Notice that the value and query section refer to the MyTable(x) definition created in the Nodes section The Nodes method defines the table name of the resulting rowset in this case, we re calling it simply MyTable By using a single column name of cols in the MyTable definition, we can identify multiple columns in the SELECT statement using the same cols identifier The result of the preceding query is shown in Figure 5-6
Figure 5-6 The result of a query using the Nodes method
The query combines the Value and Query methods to pull data out of the XML document and then displays them with the Nodes method EXAM TIP The Nodes method is an ideal solution when XML data needs to be shredded so that the different elements can be manipulated and/or stored independently Used with the Value method, it can be very effective at comparing XML data and non-XML data and putting the XML data into a relational format
Modify
The Modify method lets you execute XML Data Manipulation Language (DML) statements against XML columns This allows us to modify parts of an XML data type while retaining the integrity of the overall XML data While the XQuery language allows us to query the XML data, it doesn t let us modify it XML DML statements include:
Insert Delete Replace Value Of
Exist
Exist works the same way that the EXISTS clause works in a SELECT statement Used within an XQuery language expression, it will return a 1 if true, indicating that the embedded XQuery has a non-null result set We can use this to pull rows based on the value of individual attributes within the XML column We ll see an example of the Exist method in the XQuery section The basic syntax of the Exist method is shown in the following code The XQuery portion is an XQuery expression or a string literal
exist (XQuery)
Copyright © OnBarcode.com . All rights reserved.