想把ERP数据导出为XML文件为水晶易表用,查阅了网上很多资料,今天终于搞定,代码如下。
- if not exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[TT]') )
- CREATE TABLE TT(aa XML )
- delete from TT
- DECLARE @x XML
- SET @x = (select abc='<ly>'+(select * from t_icitem FOR XML PATH)+'</ly>')
- INSERT TT VALUES (@x)
- EXEC KILRpt_Sample.sys.xp_cmdshell 'bcp KILRpt_Sample.dbo.TT out E:/123.xml -c -T -k -C65001'
转载于:https://blog.51cto.com/1243981/1126873