-- To allow advanced options to be changed.
EXEC sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
EXEC('EXEC master..xp_cmdshell ''bcp "SELECT * FROM server3.swfc.dbo.user_tbl FOR XML AUTO, ELEMENTS" queryout "c:/xml.xml" -c -S"server3" -U"sa" -P"1234" '' ')
bcp "select * from swfc..user_tbl for xml auto, elements " queryout c:/a1.xml -c -Sserver3 -Usa -P1234
EXEC master..xp_cmdshell 'bcp "select * from swfc..user_tbl for xml auto, elements " queryout c:/a1.xml -c -Sserver3 -Usa -P1234'
本文介绍了一种通过配置SQL Server的高级选项并启用扩展存储过程XP_CmdShell来导出数据库中user_tbl表的数据为XML格式的方法。具体步骤包括允许高级选项、更新配置、启用特征并最终执行命令将数据导出到指定路径。
1381

被折叠的 条评论
为什么被折叠?



