how to Generate xml file in sql server 2005 using tsql
如何使用tsql在sql server 2005中生成xml文件
3 个解决方案
#1
4
Select Emp_Id,Emp_Name from tblEmployee Where Emp_Id < 3
For 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>
上面是Xml,而不是
#3
1
Stored proc exec DBName.dbo.Table is
proc exec DBName.dbo存储。表
select * from table for xml path
SET @SQL= 'bcp "exec DBName.dbo.Table" queryout c:\myfile.xml -w -r -t -SServerName -T'
EXEC Master..xp_CmdShell @SQL
#1
4
Select Emp_Id,Emp_Name from tblEmployee Where Emp_Id < 3
For 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>
上面是Xml,而不是
#2
#3
1
Stored proc exec DBName.dbo.Table is
proc exec DBName.dbo存储。表
select * from table for xml path
SET @SQL= 'bcp "exec DBName.dbo.Table" queryout c:\myfile.xml -w -r -t -SServerName -T'
EXEC Master..xp_CmdShell @SQL