Sql server 2005 如何把数据汇到txt文件,谢谢.

[复制链接]
查看11 | 回复6 | 2007-10-20 08:38:44 | 显示全部楼层 |阅读模式
EXEC master..xp_cmdshell 'bcp "select * from dbo.table" queryout c:\mb1111.txt -c -t,-U -Ppassword'
我这样,出现错误:Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', see "Surface Area Configuration" in SQL Server Books Online.
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
上面的参数解决了,不过执行时,出现下列图片错误,请解决,急,谢谢!
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
sql 2005 貌似没有开 xp_cmdshell 的,
SSMS中有个功能是把查询保存到文件中的,就在工具栏“注释代码”那个按钮旁边。
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
最好是通过SSIS或DTS或其他工具。
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
我也出现这个问题。。。楼主图片的问题后来怎么解决了的???
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
图片的错误说明BCP的参数使用不正确,再试一下
回复

使用道具 举报

千问 | 2007-10-20 08:38:44 | 显示全部楼层
要启动xp_cmdshell选项:

EXEC sp_configure 'show advanced options', 1
GO
RECONFIGURE
GO
EXEC sp_configure 'xp_cmdshell', 1
GO
RECONFIGURE
GO复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行