打开'xp_cmdshell'
--要先启用高级选项配置
EXEC sp_configure 'show advanced options', 1;
RECONFIGURE;
--再打开'xp_cmdshell'
EXEC sp_configure 'xp_cmdshell', 1;
RECONFIGURE;
EXEC master..xp_cmdshell 'bcp "dC.dbo.C_ListTable" out c:\tmp01.xls -c -q -S"TG-PC" -U"sa" -P"password"'
--下面是关闭
EXEC sp_configure 'xp_cmdshell', 0;
RECONFIGURE;
EXEC sp_configure 'show advanced options', 0;
RECONFIGURE;