Use the Xquery profiling element to complete XML decomposition. Remember, Xpath is a subset of Xquery. Xquery uses Xpath to describe the document part of an XML file. Use expressions such as "For, Let, Where, Order By, Return" to supplement the description, or use FLWOR (abbreviation of the preceding five words) to simplify the description. Xquery does not support update operations and full-text search. These two functions may be available in the future. However, Xquery is only a query language.
XML example
1 <sample1>
2 <company>TheRealLife</company>
3 <company>TheRealLife2</company>
4 <city>Miami</city>
5 <year-founded>1998</ year-founded>
6 <industry>software</industry>
7 </sample1>
8
Example of calling a stored procedure
1 declare @m as xml;
2 set @m = ' <sample1>
3 <company>TheRealLife</company>
4 <company>TheRealLife2</company>
5 <city>Miami</city>
6 <year-founded>1998</year-founded>
7 <industry>software</industry>
8 </sample1>'
9 exec dbo.XMLShred @d = @m;
10 Result set1:
11 TheRealLife TheRealLife2
12 Result set2:
13 <company>TheRealLife</company>
14 <company>TheRealLife2</company>
15
Stored Procedure decomposition example
1 create proc dbo.XMLShred (@d as XML)
2 AS
3 select @d.query('
4 for $step in /sample1/company
5 return string($step)
6 ')
7 select @d.query ('/sample1/company')
8 return 0;
9
Considering that the T-SQL has limited processing capabilities for complex XML operations, you can choose to use CLR stored procedures. This method is mainly based on the stored procedures implemented using Microsoft. NET Framework CLR and stored procedures that support CLR programming, such as C # Or VB. NET. Remember, in this structure, you must be able to deploy the Assembly on the physical SQL Server. Whether this is a problem depends entirely on whether the production server is locked. In addition, the Assembly must be included in the restoration scope during system restoration. Therefore, you must make a careful plan to correctly handle the disaster recovery, measurable and other impacts.