Declare @xmlDoc xml
SET @xmlDoc = (SELECT * FROM USERS AS UserTable For XML AUTO, ELEMENTS, ROOT('Root'))
SELECT @xmlDoc Result as below : <Root>
  <UserTable>
    <UserDBID>1</UserDBID>
    <UserID>Admin                           </UserID>
    <UserName>admin</UserName>
    <Password>49CE5FB6D05148ACB66A</Password>
    <FullName />
    <LocalFullName />
    <Title />
    <Department />
    <UserRole>Administrator</UserRole>
    <IsFirstLogin>0</IsFirstLogin>
    <PwdNeverExpire>1</PwdNeverExpire>
    <PwdLastModifyTime>2013-07-10T13:40:48.470</PwdLastModifyTime>
  </UserTable>
  <UserTable>
    <UserDBID>2</UserDBID>
    <UserID>cshsvc                          </UserID>
    <UserName>cshsvc</UserName>
    <Password>54C0FCD2B54CCE8BE6AD</Password>
    <FullName />
    <LocalFullName />
    <Title />
    <Department />
    <UserRole>Administrator</UserRole>
    <IsFirstLogin>0</IsFirstLogin>
    <PwdNeverExpire>1</PwdNeverExpire>
    <PwdLastModifyTime>2013-07-10T13:38:25.070</PwdLastModifyTime>
  </UserTable>
</Root> SelectEmp_Id,Emp_Namefrom tblEmployee WhereEmp_Id<3For XML AUTO,ELEMENTS
--For XML [MODE],ELEMENTS

MODE

AUTO, RAW, EXPLICIT

Result [AUTO]

<tblEmployee><Emp_Id>1</Emp_Id><Emp_Name>AAA</Emp_Name></tblEmployee><tblEmployee><Emp_Id>2</Emp_Id><Emp_Name>BBB</Emp_Name></tblEmployee>

Result [RAW]

Above Xml with Instead of <tblEmployee> here..... <ROW> and </tblEmployee> is </ROW>

SELECT ( SELECT 'White' AS Color1,
'Blue' AS Color2,
'Black' AS Color3,
'Light' AS 'Color4/@Special',
'Green' AS Color4,
'Red' AS Color5
FOR
XML PATH('Colors'),
TYPE
),
 ( SELECT 'Apple' AS Fruits1,
'Pineapple' AS Fruits2,
'Grapes' AS Fruits3,
'Melon' AS Fruits4
FOR
XML PATH('Fruits'),
TYPE
)
FOR XML PATH(''),
ROOT('SampleXML')
GO

create xml file from sql script的更多相关文章

  1. persistent.xml hibernate 利用sql script 自定义生成 table 表

    <?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http:// ...

  2. LinqToXml (一) Create Xml file By Dom /Linq

    目前,在xml 应用编程领域比较流行的开发模型是W3C 提供的DOM(文档对象模型),在.net Framework 通过命名空间 System.Xml 对该技术提供了支持.随着Linq to XMl ...

  3. Create XML Files Out Of SQL Server With SSIS And FOR XML Syntax

    So you want to spit out some XML from SQL Server into a file, how can you do that? There are a coupl ...

  4. How to Enable Trace or Debug for APIs executed as SQL Script Outside of the Applications ?

    In this Document   Goal   Solution   1: How do you enable trace for an API when executed from a SQL ...

  5. csharp:SMO run sql script

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  6. [vb.net]XML File Parsing in VB.NET

    Introduction Parsing XML files has always been time consuming and sometimes tricky. .NET framework p ...

  7. How to: Write Object Data to an XML File

    This example writes the object from a class to an XML file using the XmlSerializer class. Namespace: ...

  8. java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.LoginActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class

    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ex.activity/com.ex.activity.L ...

  9. SQL SERVER – Import CSV File Into SQL Server Using Bulk Insert – Load Comma Delimited File Into SQL Server

    CSV stands for Comma Separated Values, sometimes also called Comma Delimited Values. Create TestTabl ...

随机推荐

  1. 06易普优APS行业方案:包装印刷行业高级计划排程

    易普优APS行业方案:包装印刷行业高级计划排程 一.包装印刷行业发展概况 网络购物催生包装印刷行业迅猛发展,目前已具有万亿市场规模,全国包装印刷企业总数达30万家,其中规模以上企业只有2万多家,已然成 ...

  2. Check whether a + b = c or not after removing all zeroes from a,b and c

    Check whether a + b = c or not after removing all zeroes from a,b and c Given two integers a and b, ...

  3. java.io.BufferedWriter API 以及源码解读

    下面是java se 7 API 对于java.io.BufferedWriter 继承关系的描述. BufferedWriter可以将文本写入字符流.它会将字符缓存,目的是提高写入字符的效率. bu ...

  4. python笔记五:IO与文件

    1.python IO:  Python提供了两个内置函数从标准输入读入一行文本,默认的标准输入是键盘:  1)raw_input([prompt]) 函数从标准输入读取一个行,并返回一个字符串  2 ...

  5. Hibernate对象的状态转换

    Hibernate中的实体对象可以分为三种状态:Transient(临时).Persistent(持久).Detached(游离) Transient 用new创建出对象,这些对象还没有与数据库发生任 ...

  6. hibernate-release-4.3.11.Final资源包介绍

    资源下载 hibernate-release-4.3.11.Final documentation 包  相关文档 lib  相关jar包 required --开发中必须要加入的包 optional ...

  7. luoguP4115 QTREE4 链分治

    具体看$qzc$论文吧......陈年老物了...... 主要注意每个链头一棵线段树而不是一棵全局线段树 修改操作写完就是正确的,反而是初始化调了好一会...... 跑的还是很快的,有些地方没优化常数 ...

  8. HDU 5909 Tree Cutting(FWT+树形DP)

    [题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5909 [题目大意] 给出一棵树,其每棵连通子树的价值为其点权的xor和, 问有多少连通子树的价值为 ...

  9. 性能测试工具——Jmeter使用小结(一)

    Apache Jmeter是针对Java的一款性能测试工具,利用该工具可以实现自动化的批量测试和结果聚合,适合做接口压测.今天就来捋一捋软件安装的一些小细节和使用. 一.安装 Jmeter基于JDK, ...

  10. [BZOJ1005](HNOI 2008)明明的烦恼

    Description 自从明明学了树的结构,就对奇怪的树产生了兴趣...... 给出标号为1到N的点,以及某些点最终的度数,允许在任意两点间连线,可产生多少棵度数满足要求的树? Input 第一行为 ...