, (SELECTHobby+',' fromStudentWHERESName=A.sname forXML PATH ("')) asstulist fromStudent AGROUP bysName) BThe results are as follows:Analysis: OK, then let's analyze it, first look at this sentence:SELECT Hobby+',' from student WHERE sName=a.sname for
XML PATH (
")
This sentence is through the for XML PATH to a name like Z
DescriptionQuery () method (XML data type)This method is used to query the XML instance.Value () method (XML data type)This method is used to retrieve the value of the SQL type from an XML instance.exist () method (XML data type)T
method for XML andDISTINCTget the string that has been weighed and then assign a variableFor XML requires SQL Server 2005+ version support--new SQL method to de-redo with for XML path and distinctDECLARE @SNvarchar( -)--The resul
Server|xml Optional Element
The example allows us to learn more about the internal mechanism of the various settings, and we'll take a closer look at the optional element xmldata for the XML statement below.
If you set this option, the Xml-data schema will be included in the result set. The following is an
Sometimes it may be useful to associate or analyze data from SQL Server to other departments at once, a requirement that is certainly simple for SSIS, but a lot of times it makes a fuss to create a SSIS package just by exporting the data one at a time, while the SQL The Import Export tool for the server there are a lot
Sometimes the need to export data from SQL Server to other departments may be correlated or analyzed, which is of course very simple for SSIS, but many times it takes a lot of time to simply export the data and create an SSIS package that makes a fuss, while the SQL The Import and Export tool for the server where the b
Executing SQL statements using HTTP
Using the virtual directory we just created, we can execute the query by writing the SQL query statement to the URL. Open the browser and write in the address bar
Into the following url:http://localhost/northwind?sql=select+ *+from+customers+where+customerid= ' ANTON '
+for+xml+autor
meet the current conditionsSET @myDoc. Modify ('Insertif (count (/root/location/step) Then element step {"This is new step"}Else ()As first into (/root/location) [1] ')SELECT @myDoc;2. Update XML DECLARE @myDoc XML SET @myDoc = ' Laborhours= "1.1" Machinehours= ". 2" >manufacturing steps is described here. SELECT @myDoc; --The value of the LaborHours property in the replacement node location is
SQL Server Installation fails there is an error generating the XML document. Error code 0x84b10001.When installing mssqlserver2008 with Administrator room on WINDOWS2008R2 error occurred during installation: Generate XML error, Error Code 0x84b10001Baidu search a bunch of sites, are unsuccessful, and then query the off
server|xml| Insert | Data we know that XML types are added to SQL Server 2005, which means that you can specify a column XML type when you create a table, such as:
CREATE TABLE Customers
(
Name VARCHAR not NULL PRIMARY KEY,
Descri
The new Xml.modify () method is added to SQL Server, xml.modify (insert), xml.modify (delete), xml.modify (replace) to insert, delete, and modify the XML.
This article takes the following XML as an example to illustrate three types of DML:
Declare
@XMLVar XML = '
'
1.
1. Get the number of nodes under a node in the XML typeDECLARE @xmlXMLSET @xml = '';SELECT @xml. Value ('count (/parameters/parameter)','int')2. Turn XML into tableDECLARE @xmlXMLSET @xml = '';SELECTT.c.query ('.'). Value ('(//@name) [1]','varchar (+)') asA, T.c.query ('.').
Server|xml private String Getforxml (String sfile, string sSQL)
{
Create and open the connection to Northwind
DataSet oDs = new DataSet ();
using (SqlConnection oCn = new SqlConnection (ConnectionString))
{
Ocn.open ();
Create the SQL command to execute
SqlCommand ocmd = new SqlCommand (sSQL, oCn);
System.Diagnostics.Debug.WriteLine (sSQL);Execute the
Label:Tools to use:
Sql server
Java
MyBatis
First step: Create a function to get the data in the XMLCREATE function create_table (@str XML) returns @tb table (SourceID varchar) asbegin INSERT INTO @tb SELECT v.value (' @sourceId [1] ', ' VARCHAR ') as SourceIDfrom @str. Nodes ('/ Rsssources/rsssource ') x (v)
Tags: SQL Server extended Server 2012 Extended Events/*******There's a small difference between R2 and*****/CREATE EVENT SESSION [test] on SERVERADD EVENT sqlserver.sql_statement_completed(SET collect_statement= (1)ACTION(Sqlserver.client_app_name,Sqlserver.client_hostname,SQLSERVER.DATABASE_ID,Sqlserver.database_name,Sqlserver.sql_text,sqlserver.username)WHERE (
Tags: data usage exp Data character rom specify CTE insertSample table TB data is as follows ID value—————1 AA1 BB2 AAA2 BBB2 CCC SELECT ID,[Val] = (SELECT [value] + ', 'From TB as BWHERE b.id = a.id for XML PATH ("))From TB as a Show results1 AA,BB,1 AA,BB,2 AAA,BBB,CCC,2 AAA,BBB,CCC,2 AAA,BBB,CCC, SELECT ID,[Val]= (SELECT [value] + ', 'From TB as BWHERE b.id = a.idFor XML PATH (")")From TB as aGROUP by I
XPath query schemas and templates
An XPath query can also be embedded into an XML template file, and the following code is a simple XML template file that contains an XPath query.
"Urn:schemas-microsoft-com:
Xml-sql ">
"File4.xdr" >
/customer[@CustomerID =
' ALFKI ']/order
This query uses a schema (schema) to return al
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.