现在的位置: 首页 > 综合 > 正文

SQL 中使用系统存储过程生成xml文件的试例

2012年11月15日 ⁄ 综合 ⁄ 共 472字 ⁄ 字号 评论关闭

--Generate xml file from dataSource
USE [Northwind]
GO

EXEC sp_makewebtask
@outputfile = 'd:\shippers.xml',
@query='SELECT * FROM [shippers] FOR XML AUTO',
@templatefile='D:\shippers.txt'

------------------------------------------------------

USE [Northwind]
GO

DECLARE @FileName VARCHAR(50),@bcpCommand VARCHAR(2000)

SET @FileName = 'D:\shippers.txt'
SET @bcpCommand = 'bcp "select * from Northwind..shippers " query out "'
SET @bcpCommand = @bcpCommand + @FileName + '" -T -c -t "~|~" -r "^$^"'

EXEC master..xp_cmdshell @bcpCommand

抱歉!评论已关闭.