SQL Server for XML Path some may not know others. In fact, it shows the query result set in XML format, with this feature, we can simplify our query statements to implement some work that may previously need to be completed through the function live storage process. Take an instance as the main type.
1. for XML Path
F
in this article to describe the parameters received by openxml. For more information, refer to the Bol. Search openxml in the Transact-SQL reference.
Now we have reached the final step. All the remaining work is to import an actual XML file to the SQL and process it. (It's amazing why this is not involved in all the Bol examples.Key ). (I must thank my colleague
Copy codeThe Code is as follows:/* 01.02. SQL xml entry:03. -- by jinjazz04. -- http://blog.csdn.net/jinjazz05.06. 1. xml: Recognition of elements, attributes, and values07.. Xpath: Addressing language, similar to windows Directory Search (if you have never used the dir command, go to the wall)09.10. Syntax format. These syntaxes can be combined into conditions:1
Label:In SQL, it is often necessary to synthesize multiple rows of data into one line below is a brief introduction to using the for XML path.1, convert the Tuyi to figure two: 1 select ArticleID, 2 (select convert (varchar (10 ), TagID) + " " from 3 for
the SQL and process it (very fast why none of the BOL examples involve this critical part). (I must thank my colleague Billy Pang for the help he has given me.) He helped me solve the problem and gave the code--although I needed to cut the code for this article. Thank you billy!) The basic trick is to read the file line by text. Then connect all the read rows to a large varchar variable. Finally, pass the
process it (very fast why none of the BOL examples involve this critical part). (I must thank my colleague Billy Pang for the help he has given me.) He helped me solve the problem and gave the code--although I needed to cut the code for this article. Thanks, billy!. The basic trick is to read the file line by text. Then connect all the read rows to a large varchar variable. Finally, pass the variable to the code described earlier.
Here's the code to
') Select @xmlDoc. Query (' (/root/book) [1] ') Run results 6 , modify Properties Modifying property values is also very common, such as modifying the ID property of the book node with ID 0001 to 0005, which we can use as follows: --Modify properties Set @xmlDoc. Modify (' Replace value ' of (root/book[@id = "0001"]/@id) [1] with "0005" ') Select @xmlDoc. Query (' (/root/book) [1] ') Run results OK, after the study above, I believe you can already use the
If you work in it, you probably have heard of XML, but if your job is primarily about SQL Server, you may not be using XML directly. XML is already a popular data format in the Web programming environment, and it is one of the main underlying technologies in the. NET framework. SQL
discussed the JSTL expression language (expression Language,el) and the core and FMT tag libraries. In the last installment, we'll consider the SQL and XML libraries--as their names indicate--to provide custom tags to access and manage data retrieved from SQL databases and XML files.
, Passwd,deptno, Deptname, DEPTSERVER,DEPTDATABASE,BZ, convert (nvarchar (80), Createtime as Createtime, convert (nvarchar, regtime,) as Regtime,parcomcode,parcomname,parcomserver, Parcomdatabase,mustparcom,lxr,tel,email, Handtel,nprop,nreg,parcomdataserver,deptdataserver,ftpuser,ftppass from UserInfo FOR XML Auto "' has date-time fieldsCmdser.properties ("
Insert Table
SELECT * into #temp the From OPENROWSET (
BULK ' E:\xml.xml ', Single_blob) as X
DECLARE @hdoc int
DECLARE @doc XML
Select @doc =bulkcolumn from #temp
EXEC sp_xml_preparedocument @hdoc OUTPUT, @doc
SELECT * into #temp2
From OPENXML (@hdoc, N '/root/dbo.xmltable ')
With (name nvarchar, Intro nvarchar (20))
EXEC sp_xml_removedocument @hdoc
/*
Processing of---Empty
1
2 NULL
3 C
*/
drop table XMLT
------------------------------------
Tags: function apply arc font var. project Bubuko GPO Body Count SELECT * from Tbiz_projectrelation Target statistics each project has several application records Step1 SELECTProjectID, Relationids= STUFF((SELECT ',' + CONVERT(VARCHAR,[Relationid]) fromTbiz_projectrelation TWHEREProjectID=T1. ProjectID forXML PATH ("')),1,1,"')
fromTbiz_projectrelation T1 Step2 SELECTProjectID, Relationids= STUFF((SELECT
Declare @ hdoc int -- document handleDeclare @ xmlstring varchar (200) -- XML stringSet @ xmlstring = '-- Analyze the XML string using the system stored procedure sp_xml_preparedocumentExec sp_xml_preparedocument @ hdoc output, @ xmlstring-- Use openxml to query data from the internal cache of SQL ServerSelect * From o
information for books that are not Japanese (lang!= "JP") and are priced at more than 35
SelectT.c.value ('Title[1]','varchar (max)') astitle, T.c.value ('Year[1]','int') as Year, T.c.value ('Title[1]','varchar (max)') astitle, T.c.value ('Price[1]','float') asPrice , T.c.value ('Author[1]','varchar (max)') asAuthor1, T.c.value ('Author[2]','
1. xml. exist
If the input is an XQuery expression, 0, 1 or Null is returned. 0 indicates no, 1 indicates yes, and Null indicates that the input is Null.
2. xml. value
The input is an XQuery expression and returns an SQL Server scalar value.
3. xml. query
The input is an XQuery expression and returns an
-based applications. Because there are a large number of XML standards for data transmission through the Web, it is vital to provide the XML function in RPG. RPG programmers must realize that the native XML data type introduced by DB2 for I is to support embedded SQL (including RPG) various programming languages provid
@XML xmlselect @XML = ' 2. Implement reading of multiple data xmlSince each XML data is likely to have multiple data, here I use a cursor, each time I traverse a piece of data, read the XML, and then insert the data from the data into the updateDECLARE @ID VARCHAR DECLARE @
Sometimes we need to save the data read from the database as XML directly. Here we can achieve this through SQL statements.
Sometimes we need to save the data read from the database as XML directly. Here we can achieve this through SQL statements.
First, create a table:
The Code is as follows:
USE [ip]
GO
/***** Obje
1. xml. existIf the input is an XQuery expression, 0, 1 or null is returned. 0 indicates no, 1 indicates yes, and null indicates that the input is null.2. xml. ValueThe input is an XQuery expression and returns an SQL Server scalar value.3. xml. QueryThe input is an XQuery expression and returns an
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.