sql server - SQL - How to assign a record in a variable -


AIM: Convert an XML to XML and specify the result in a variable

set the result :

  M000017690 324067342 324067349 324067355 324154449  

Convert XML:

  & lt; Products & gt; & Lt; Product ProductId = "324067342" /> & Lt; Product ProductId = "324067349" /> & Lt; Product ProductId = "324067355" /> & Lt; Product Product ID = "324154449" /> & Lt; Product Product ID = "M000017690" /> & Lt; / Products & gt;  

The following query I used to convert the resultset (above) to XML:

  Select 1 AS tag, NULL AS Parent, NULL as [product! 1! Product Id], as the tap [product! 2! Product ID, template for @ Templation Union, as template 2, 1 ISI Original, Product ID, Product ID, XML Exhibit with XML  

Now let me give this XML to another stored procedure Which requires a parameter type: XML is the basic idea to create an XML type object:

  declaration @xml_data as XML  

and assign the result of the query to this variable, I can add @xml_data Query results How can I specify?

How about this (works on SQL Server 2005 and above):

 Announcement @xmlldata XML @xmlData = (SELECT ProductId as '@productId' FROM @ Template for XML ('Product'), Route ('Product')) @ XML Data  

mark


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -