导出 EXCEL 文件

来源:互联网 发布:数据报网络 编辑:程序博客网 时间:2024/06/07 14:53
--1. 开启 xp_cmdshell . 注:风险较高, 用完要关闭EXEC sp_configure 'show advanced options', 1GORECONFIGURE WITH OVERRIDE;GOEXEC sp_configure 'xp_cmdshell', 1GORECONFIGURE WITH OVERRIDE;GO--2.1 sql 账户导出EXEC master..xp_cmdshell 'bcp "select 1 as r" queryout "d:\test.xls" -c -S".\sqlserver2014" -U"userName" -P"password" '--2.2 windows账户导出EXEC master..xp_cmdshell 'bcp "select 1 as r" queryout "d:\test2.xls" -c -S".\sqlserver2014" -T '--2.3 根据存储过程导出EXEC master..xp_cmdshell 'bcp "EXEC [AdventureWorks2014].dbo.Proc_Test" queryout "d:\test2.xls" -c -S".\sqlserver2014" -T '


参考:点击打开链接
原创粉丝点击