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作为行分隔符,\n作为断行符 导出到H盘
EXECUTE master.dbo.xp_cmdshell 'bcp "SELECT TOP 20 PERCENT * FROM MyDB.dbo.table_name" queryout H:\table_name.dat -c -T'

 

 

posted @ 2015-07-02 10:38  Jerry_Chen  阅读(349)  评论(0编辑  收藏  举报