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 ...
随机推荐
- js求连个数之间的数字
整理出自项目中一个需求,求两个数之间的数字. const week = function(arr,arr2){ let a=parseInt(arr); let b=parseInt(arr2); l ...
- c++ 单例模式研究
一篇博文:C++ 单例模式的几种实现研究 中 看到的几段代码 懒汉模式 class Singleton { public: static Singleton* GetInstance() { if ( ...
- 隐藏当前Activity而不关闭
startActivity后调用 overridePendingTransition(R.anim.zoomin, R.anim.zoomout); 可以实现Activity跳转的动画效果 打开act ...
- 【Java学习】调用ByteBuffer.getInt()方法得到808464432
调用ByteBuffer.getInt()方法遇到的奇怪错误 最近在参加阿里的中间件比赛,中间用到了RocketMQ的思想,并且主要集中在使用NIO来读写文件.其中遇到了一个很蛋疼的问题,想了半天想不 ...
- 修复mysql
REPAIR TABLE TABLENAME 或 REPAIR TABLE TABLENAME USE_FRM
- Redis学习篇(七)之事务
Redis中的事务 开启事务 MULTI:开启事务,事务块中多条语句会按照顺序放入队列当中,最后由EXEC来执行 MULTI INCT counter1 INCR counter2 INCR coun ...
- FastReport.Net使用:[37]报表继承
1.设计一个基础报表,将其保存为BaseReport. 2.新建一个继承的报表. 通过 文件-->新建 打开“新建对象”向导.选择“继承的报表”,点击确定. 3. 在打开对话框中选择基础报表Ba ...
- 顺序存储线性表_ArrayList
相信大家在日常开发过程中 List 应该使用的非常非常多,今天就来简单学习一下 List 的数据结构 顺序存储线性表. 一.什么是顺序存储线性表 顺序存储线性表是最基本.最简单.也是最常用的一种数据结 ...
- 【BZOJ 3566】 3566: [SHOI2014]概率充电器 (概率树形DP)
3566: [SHOI2014]概率充电器 Description 著名的电子产品品牌 SHOI 刚刚发布了引领世界潮流的下一代电子产品——概率充电器:“采用全新纳米级加工技术,实现元件与导线能否通电 ...
- AC自动机详解(附加可持久化AC自动机)
AC自动机 AC自动机,说白了就是在trie树上跑kmp(其实个人感觉比kmp容易理解).是一种多匹配串,单个主串的匹配.概括来说,就是将多个匹配串构造一个trie树,对于每个trie树的节点构造nx ...