EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO
exec master..xp_cmdshell 'bcp "SELECT SOME FROM 数据库.dbo.表 " queryout "D:1.txt" -c -t -S服务器 -U账号 -P密码'
GO
EXEC sp_configure 'xp_cmdshell', 0
GO
RECONFIGURE
GO
EXEC sp_configure 'show advanced options', 0
GO
RECONFIGURE
GO