create xml file from sql script
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的更多相关文章
- persistent.xml hibernate 利用sql script 自定义生成 table 表
<?xml version="1.0" encoding="UTF-8"?> <persistence xmlns="http:// ...
- LinqToXml (一) Create Xml file By Dom /Linq
目前,在xml 应用编程领域比较流行的开发模型是W3C 提供的DOM(文档对象模型),在.net Framework 通过命名空间 System.Xml 对该技术提供了支持.随着Linq to XMl ...
- 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 ...
- 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 ...
- csharp:SMO run sql script
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- [vb.net]XML File Parsing in VB.NET
Introduction Parsing XML files has always been time consuming and sometimes tricky. .NET framework p ...
- 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: ...
- 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 ...
- 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 ...
随机推荐
- 为啥我喜欢在Windows 7环境下做Unity开发?
先说明,以下情况只针对本人哦~ 前阵子我在OSX的最新版本Mavericks下做Unity开发,后来我把MacbookPro卖了,自己组装了个PC搞开发,为啥呢? 1:OSX下 MonoDevelop ...
- js的循环
1.for(){} 这种方法可能每个人都用过,不多说. 2.ES5的forEach myArray.forEach(function (value) { console.log(value); }); ...
- go chapter 9 - 反射
https://www.cnblogs.com/diegodu/p/5590133.html // 反射,根据字段名设置值 package entities import( "reflect ...
- 2017/11/5 Leetcode 日记
2017/11/5 Leetcode 日记 476. Number Complement Given a positive integer, output its complement number. ...
- misaka and last order SCU - 4489 (筛法的灵活应用)
Time Limit: 1000 MS Memory Limit: 131072 K Description Misaka Mikoto is a main character of the Anim ...
- 我的sublime text3 配置文件设置
{ "ignored_packages": [ "Vintage" ], //vim模式 "line_padding_bottom": 2, ...
- 【BZOJ 4596】 4596: [Shoi2016]黑暗前的幻想乡 (容斥原理+矩阵树定理)
4596: [Shoi2016]黑暗前的幻想乡 Time Limit: 20 Sec Memory Limit: 256 MBSubmit: 324 Solved: 187 Description ...
- 【BZOJ 3561】 3561: DZY Loves Math VI (莫比乌斯,均摊log)
3561: DZY Loves Math VI Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 205 Solved: 141 Description ...
- android 传递 类对象 序列化 Serializable
public class Song implements Serializable { /** * */ private static final long serialVersionUID = 64 ...
- [BZOJ4552][TJOI2016&&HEOI2016]排序(二分答案+线段树/线段树分裂与合并)
解法一:二分答案+线段树 首先我们知道,对于一个01序列排序,用线段树维护的话可以做到单次排序复杂度仅为log级别. 这道题只有一个询问,所以离线没有意义,而一个询问让我们很自然的想到二分答案.先二分 ...