--首先开启 xp_cmdshell
EXEC
sp_configure 'show advanced options', 1
GO
-- To update the currently configured value for advanced options.
RECONFIGURE
GO
-- To enable the feature.
EXEC
sp_configure 'xp_cmdshell', 1
GO
-- To update the currently configured value for this feature.
RECONFIGURE
GO
----实现导出
use master
declare @cmd varchar(5000)
set @cmd= 'bcp "select * from [数据库名称].[dbo].[表名]" queryout "磁盘路径+文件名称 " -c -T '
exec master..xp_cmdshell @cmd
SqlServer将数据库中的表导出到excel中
最新推荐文章于 2024-04-01 16:36:14 发布