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 ...
随机推荐
- Eclipse中用两个控制台测试网络通信程序
1.启动发送端和接收端程序,这时在控制台可以看到两个程序在运行,如下图. 2.这种情况下只有一个控制台窗口,不便于测试程序,于是新建一个控制台窗口,如下图. 3.这时可以发现已经有了两个控制台窗口了, ...
- ubuntu下让进程在后台运行
(1)输入命令: nohup 你的shell命令 & (2)回车,使终端回到shell命令行: (3)使用第二第三条,完全屏蔽掉信号 用disown -h jobspec来使某个作业忽略HUP ...
- 计算机二级C考试有感
细节细节细节,细节决定成败,记不熟的玩意就是知识点的漏洞. 总结一下这次考试我没有掌握好的知识点. 1,sizeof() sizeof() 是计算具体所占的空间大小 char[7]就是7 int[7] ...
- redis和mySql的数据同步的解析
1.同步MySQL数据到Redis (1) 在redis数据库设置缓存时间,当该条数据缓存时间过期之后自动释放,去数据库进行重新查询,但这样的话,我们放在缓存中的数据对数据的一致性要求不是很高才能放入 ...
- 为什么我喜欢Java
我现在的老板使用一个在线测试系统来筛选在线申请职位的求职者.测试的第一个问题很浅显,仅仅是为了让求职者熟悉一下这个系统的提交和测试代码的流程.问题是这样的,写一个将标准输入拷贝到标准输出的流程.求职者 ...
- ddms 安卓录制
韩梦飞沙 韩亚飞 313134555@qq.com yue31313 han_meng_fei_sha 屏幕录制, 视频录制 保存为 . 打开 .显示在浏览器里. 设备屏幕捕捉 刷 ...
- 什么是P问题、NP问题和NPC问题
为了迎接我的期末考试,认真的看了一下关于NP完全性理论这一章,奈何课本上说的我怎么都看不懂,所以找了个博客认真研究了一下,同样贴出来分享给大家,大牛就是大牛,把问题说的很明白,看完后受益匪浅.其中有一 ...
- [NC13B]贝伦卡斯泰露/[51Nod1400]序列分解
[NC13B]贝伦卡斯泰露/[51Nod1400]序列分解 题目大意: 给定\(A_{1\sim n}(n\le40)\),问是否能将\(A\)分解成两个相同的子序列? 思路: 折半搜索.时间复杂度\ ...
- django自定义分页控件
1.准备数据 在models创建测试表 from django.db import models class Host(models.Model): hostname = models.CharFie ...
- python开发_bisect
现在有如下的需求: ''' 实现这样的一个功能: 对一个班级的学生的成绩做出一些评定,评定规则是: one: [0-60) -- F two: [60-70) -- D three: [70-80) ...