BCP命令导出表数据到文件

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

猜你喜欢

转载自huzhupo.iteye.com/blog/2165625
今日推荐