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