把数据库中表的内容转存为XML文件
2023-09-14 08:57:24 时间
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
把数据库中表的内容转存为XML字符串
(1)
SELECT TOP 2
*
FROM dbo.ProductProperty
FOR XML PATH
<row>
<ProductPropertyID>1</ProductPropertyID>
<Code>BU93</Code>
<Weight>0.053500</Weight>
<DistributeAreaID>3</DistributeAreaID>
<IsThirdStock>0</IsThirdStock>
<CreateUser>system</CreateUser>
<CreateDate>2013-05-15T10:55:12.737</CreateDate>
<LastUpdUser>system</LastUpdUser>
<LastUpdDate>2013-05-15T17:31:49.380</LastUpdDate>
</row>
<row>
<ProductPropertyID>2</ProductPropertyID>
<Code>BU95</Code>
<Weight>0.073500</Weight>
<DistributeAreaID>3</DistributeAreaID>
<IsThirdStock>0</IsThirdStock>
<CreateUser>system</CreateUser>
<CreateDate>2013-05-15T10:55:12.737</CreateDate>
<LastUpdUser>system</LastUpdUser>
<LastUpdDate>2013-05-15T10:55:12.737</LastUpdDate>
</row>
(2)
SELECT TOP 2
*
FROM dbo.ProductProperty
FOR XML AUTO ,
ROOT('root')
返回
<root>
<dbo.ProductProperty ProductPropertyID="1" Code="BU93" Weight="0.053500" DistributeAreaID="3" IsThirdStock="0" CreateUser="system" CreateDate="2013-05-15T10:55:12.737" LastUpdUser="system" LastUpdDate="2013-05-15T17:31:49.380" />
<dbo.ProductProperty ProductPropertyID="2" Code="BU95" Weight="0.073500" DistributeAreaID="3" IsThirdStock="0" CreateUser="system" CreateDate="2013-05-15T10:55:12.737" LastUpdUser="system" LastUpdDate="2013-05-15T10:55:12.737" />
</root>
(3)
SELECT TOP 2
*
FROM dbo.ProductProperty
FOR XML AUTO ,
ROOT('root') ,
ELEMENTS
返回:
<root>
<dbo.ProductProperty>
<ProductPropertyID>1</ProductPropertyID>
<Code>BU93</Code>
<Weight>0.053500</Weight>
<DistributeAreaID>3</DistributeAreaID>
<IsThirdStock>0</IsThirdStock>
<CreateUser>system</CreateUser>
<CreateDate>2013-05-15T10:55:12.737</CreateDate>
<LastUpdUser>system</LastUpdUser>
<LastUpdDate>2013-05-15T17:31:49.380</LastUpdDate>
</dbo.ProductProperty>
<dbo.ProductProperty>
<ProductPropertyID>2</ProductPropertyID>
<Code>BU95</Code>
<Weight>0.073500</Weight>
<DistributeAreaID>3</DistributeAreaID>
<IsThirdStock>0</IsThirdStock>
<CreateUser>system</CreateUser>
<CreateDate>2013-05-15T10:55:12.737</CreateDate>
<LastUpdUser>system</LastUpdUser>
<LastUpdDate>2013-05-15T10:55:12.737</LastUpdDate>
</dbo.ProductProperty>
</root>
(1)
SELECT TOP 2
*
FROM dbo.ProductProperty
FOR XML PATH
<row>
<ProductPropertyID>1</ProductPropertyID>
<Code>BU93</Code>
<Weight>0.053500</Weight>
<DistributeAreaID>3</DistributeAreaID>
<IsThirdStock>0</IsThirdStock>
<CreateUser>system</CreateUser>
<CreateDate>2013-05-15T10:55:12.737</CreateDate>
<LastUpdUser>system</LastUpdUser>
<LastUpdDate>2013-05-15T17:31:49.380</LastUpdDate>
</row>
<row>
<ProductPropertyID>2</ProductPropertyID>
<Code>BU95</Code>
<Weight>0.073500</Weight>
<DistributeAreaID>3</DistributeAreaID>
<IsThirdStock>0</IsThirdStock>
<CreateUser>system</CreateUser>
<CreateDate>2013-05-15T10:55:12.737</CreateDate>
<LastUpdUser>system</LastUpdUser>
<LastUpdDate>2013-05-15T10:55:12.737</LastUpdDate>
</row>
(2)
SELECT TOP 2
*
FROM dbo.ProductProperty
FOR XML AUTO ,
ROOT('root')
返回
<root>
<dbo.ProductProperty ProductPropertyID="1" Code="BU93" Weight="0.053500" DistributeAreaID="3" IsThirdStock="0" CreateUser="system" CreateDate="2013-05-15T10:55:12.737" LastUpdUser="system" LastUpdDate="2013-05-15T17:31:49.380" />
<dbo.ProductProperty ProductPropertyID="2" Code="BU95" Weight="0.073500" DistributeAreaID="3" IsThirdStock="0" CreateUser="system" CreateDate="2013-05-15T10:55:12.737" LastUpdUser="system" LastUpdDate="2013-05-15T10:55:12.737" />
</root>
(3)
SELECT TOP 2
*
FROM dbo.ProductProperty
FOR XML AUTO ,
ROOT('root') ,
ELEMENTS
返回:
<root>
<dbo.ProductProperty>
<ProductPropertyID>1</ProductPropertyID>
<Code>BU93</Code>
<Weight>0.053500</Weight>
<DistributeAreaID>3</DistributeAreaID>
<IsThirdStock>0</IsThirdStock>
<CreateUser>system</CreateUser>
<CreateDate>2013-05-15T10:55:12.737</CreateDate>
<LastUpdUser>system</LastUpdUser>
<LastUpdDate>2013-05-15T17:31:49.380</LastUpdDate>
</dbo.ProductProperty>
<dbo.ProductProperty>
<ProductPropertyID>2</ProductPropertyID>
<Code>BU95</Code>
<Weight>0.073500</Weight>
<DistributeAreaID>3</DistributeAreaID>
<IsThirdStock>0</IsThirdStock>
<CreateUser>system</CreateUser>
<CreateDate>2013-05-15T10:55:12.737</CreateDate>
<LastUpdUser>system</LastUpdUser>
<LastUpdDate>2013-05-15T10:55:12.737</LastUpdDate>
</dbo.ProductProperty>
</root>
相关文章
- XML概念定义以及如何定义xml文件编写约束条件java解析xml DTD XML Schema JAXP java xml解析 dom4j 解析 xpath dom sax详解编程语言
- Linux读取XML文件的快速方法(linux读取xml文件)
- CVS文件快捷导入MySQL数据库(cvs导入mysql)
- Oracle数据库参数配置文件的管理(oracle参数文件)
- Oracle 数据库如何高效保存和管理XML数据?(oracle保存xml)
- Linux 下监控文件变化的方法(监控文件变化linux)
- 轻松学习:Linux如何修改XML文件(linux修改xml)
- 文件Linux如何快速删除文件后缀(linux删除后缀)
- Linux简单高效读取XML文件(linux读xml)
- 利用Oracle数据库写入文件的方式(oracle写文件方式)
- C DBF文件导入MySQL数据库的方法(c dbf导入mysql)
- 使用MySQL和XML注释提升数据库设计效率(mysql xml 注释)
- 文件,使用方法如何(mysql不是可执行)
- Oracle中XML文件解析技术探究(oracle中xml解析)
- oracle数据库管理中使用SMD文件的优势(oracle smd文件)
- 给你的数据库文件减肥