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

posted @ 2007-07-17 10:40  charles  阅读(827)  评论(0编辑  收藏  举报