-- 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'