sql| templates | perform
A, create a template file that contains a simple SELECT statement.
<?xml version= "1.0" encoding= "UTF-8"?>
<root xmlns:sql= "Urn:schemas-microsoft-com:xml-sql" >
<sql:query>
Select Top Customerid,companyname from customers for XML auto
</sql:query>
</root>
The template is executed in the file (Temp.xml) and through the URL:http://localhost/template/temp.xml, the result is as follows:
<?xml version= "1.0" encoding= "UTF-8"?>
-<root xmlns:sql= "Urn:schemas-microsoft-com:xml-sql" >
<customers customerid= "ALFKI" companyname= "Alfreds Futterkiste"/>
<customers customerid= "Anatr" companyname= "Ana Trujillo emparedados y helados"/> <customers customerid= "ANTON "Companyname=" Antonio Moreno taquería "/>
<customers customerid= "Arout" Companyname= "Around the Horn"/>
</root>
B, execute the stored procedure in the template file.
To build a stored procedure in SQL Server CategoryInfo:
If exists (select name from sysobjects where
Name= "CategoryInfo" and type= "P"
Drop procedure CategoryInfo
Go
CREATE PROCEDURE dbo. CategoryInfo
As
Select Categoryid,categoryname from Categories where
categories.categoryid=2 FOR XML Auto
The template is stored in a file (Temp1.xml) and executed via a URL:http://localhost/template/temp1.xml, the results are as follows:
<?xml version= "1.0" encoding= "UTF-8"?>
-<root xmlns:sql= "Urn:schemas-microsoft-com:xml-sql" >
<categories categoryid= "2" categoryname= "condiments"/>
</root>