SQL SERVER ->> BCP导出数据到平面文件

--开启xp_cmdshell
sp_configure ‘show advanced options’, 1;
GO
RECONFIGURE;
GO
sp_configure ‘xp_cmdshell’, 1; --Switch on specific functionality
GO
RECONFIGURE;
GO


--Tab作为行分隔符,
作为断行符 导出到H盘
EXECUTE master.dbo.xp_cmdshell 'bcp "SELECT TOP 20 PERCENT * FROM MyDB.dbo.table_name" queryout H:	able_name.dat -c -T'

 

原文地址:https://www.cnblogs.com/jenrrychen/p/4615361.html