1,SQL Server中执行以下命令,即可将表导出到文件。
EXEC master..xp_cmdshell 'bcp DBNAME.USER.TABLENAME out D:\aa.txt -c -S172.20.20.1\DBNAME -U"sa" -P"sa"'
2,开启xp_cmdshell :
EXEC sp_configure 'show advanced options',1;
GO
RECONFIGURE;
GO
EXEC SP_configure 'xp_cmdshell',1;
GO
RECONFIGURE;
GO