Executing SQL queries using templates

Source: Internet
Author: User
Tags sql query version xmlns
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>



Large-Scale Price Reduction
  • 59% Max. and 23% Avg.
  • Price Reduction for Core Products
  • Price Reduction in Multiple Regions
undefined. /
Connect with us on Discord
  • Secure, anonymous group chat without disturbance
  • Stay updated on campaigns, new products, and more
  • Support for all your questions
undefined. /
Free Tier
  • Start free from ECS to Big Data
  • Get Started in 3 Simple Steps
  • Try ECS t5 1C1G
undefined. /

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.