用Sql直接导出XML文件操作

 
--Generate xml file from dataSource
USE [Northwind]
GO
EXEC sp_makewebtask
@outputfile = 'd:\51aspx.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 @ 2008-07-03 10:50  superfang  阅读(487)  评论(0编辑  收藏  举报