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. python快速教程-vamei

    2016年10月26日 12:00:53 今天开始着手python的学习,希望能高效快速的学完! Python基础(上)... 7 实验简介... 7 一.实验说明... 8 1. 环境登录... 8 ...

  2. spring_150901_hibernate_transaction_xml

    实体类: package com.spring.model; import javax.persistence.Entity; import javax.persistence.Id; import ...

  3. Java经典设计模式之七大结构型模式

    转载: Java经典设计模式之七大结构型模式 博主在大三的时候有上过设计模式这一门课,但是当时很多都基本没有听懂,重点是也没有细听,因为觉得没什么卵用,硬是要搞那么复杂干嘛.因此设计模式建议工作半年以 ...

  4. GETATTR,DELATTR,SETATTR与GETITEM,SETITEM,DELITEM区别

    通过对象.属性的方式触发的是__getattr__,__delattr__,__setattr__ 通过对象['属性']触发__getitem__,__setitem__,__delitem__ cl ...

  5. 【Python初级】由生成杨辉三角代码所思考的一些问题

    杨辉三角定义如下: 1 / \ 1 1 / \ / \ 1 2 1 / \ / \ / \ 1 3 3 1 / \ / \ / \ / \ 1 4 6 4 1 / \ / \ / \ / \ / \ ...

  6. QT学习笔记2:QT中常用函数

    一.QString转number QString number() QString number() QString number() QString number() QString number( ...

  7. FileZilla提权的过程

    话不多说,我们直接操作! 首先我们通过 webshell 找到 FileZilla 的文件目录,找到 FileZilla Server Interface.xml 文件,打开.我们可以看到它的连接地址 ...

  8. mvc-单例多线程模式

    以spring mvc 为例子 spring mvc 的Controller类默认Scope是单例(singleton) 测试结果发现spring3中的controller默认是单例的,若是某个con ...

  9. Configuring spartan 6 using mcu and spi flash

    http://forums.xilinx.com/t5/General-Technical-Discussion/Configuring-spartan-6-using-mcu-and-spi-fla ...

  10. SQLSERVER里面RR隔离级别没有GAP锁

    http://www.cnblogs.com/MYSQLZOUQI/articles/3862721.html