SQL 中使用系统存储过程生成xml文件的试例
--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