一、‘xp_cmdshell’的启用
SQL Server阻止了对组件‘xp_cmdshell’的过程‘sys.xp_cmdshell’的访问。因为此组件已作为此服务嚣安全配置的一部分而被关 闭。系统管理员可以通过使用sp_configure启用‘xp_cmdshell’。有关启用‘xp_cmdshell’的详细信息
解决方法:
通过查询分析器,选择Master数据库,然后执行以下SQL内容:
sp_configure 'show advanced options',1 reconfigure go sp_configure 'xp_cmdshell',1 reconfigure go
2、开始 --> SQL安装目录 --> 配置 SQL server managerment 外围应用配置器-->“功能的外围应用配置器”-->找到“xp_cmdshell”点击启用
二、SQLState = S0002, NativeError = 208 Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]对象名 'XXX' 无效。
SQLState = 37000, NativeError = 8180
Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]无法预定义语句。
解决方法: 数据表名补全 [库名].[用户名].[表名]
exec xp_cmdshell 'bcp " select * from [库名].[用户名].[表名]" queryout " 路径 " -T -c -U -P '
三、SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Server Native Client 10.0]无法打开 BCP 主数据文件
解决方法:检查存储文件路径是否正正确,磁盘是否存在
四、在执行 sp_xp_cmdshell_proxy_account 的过程中出错。可能原因: 提供的帐户无效或无法创建 '##xp_cmdshell_proxy_account##' 凭据。错误代码: '0'。
master-->可编程性-->扩展存储过程-->系统扩展存储过程-->xp_cmdshell-->右键 属性-->权限--->添加当前执行用户--》勾选“执行”
整体解决方法 存储过程
CARATE PROCEDURE execname @filename nvarchar(4000),@path nvarchar(2000) AS BEGIN declare @sql nvarchar(4000) set @path=Replace (@path,'\\','/'); --替换路径符号 set @filename=Replace (@filename,'from ','from [库名].[用户名].'); --添加数据表全名 set @sql='bcp "'+@filename+'" queryout "'+@path+'" -T -c -U用户名 -P密码' exec xp_cmdshell @sql END
继续阅读与本文标签相同的文章
-
精读《使用 css 变量生成颜色主题》
2026-05-19栏目: 教程
-
震撼!全球首台“智慧旅游黑科技车”现身井陉……
2026-05-19栏目: 教程
-
科技产品没有时尚力?搜狗AI录音笔,要科技更要时尚
2026-05-19栏目: 教程
-
安!排!微信聊天记录的最佳恢复方法,拿走不谢!
2026-05-19栏目: 教程
-
一线丨滴滴与清华成立未来出行联合研究中心
2026-05-19栏目: 教程
