sqlserver中关于XP_CMDSHELL应用的难题

[复制链接]
查看11 | 回复0 | 2011-2-18 11:43:35 | 显示全部楼层 |阅读模式
declare
@erro_sql nvarchar(128) ----cmd 调用执行的语句
--set @erro_sql='set @erro_type=errono 001 & echo [email=%@erro_type%]%@erro_type%>>D:\07script\testdbbak\erro.log'[/email]
set @erro_sql='D:\07script\testdbbak\1.bat'
---以下是1.bat的脚本内容
---set @erro_type=errono 001
--echo [email=%@erro_type%]%@erro_type%[/email] >> D:\07script\testdbbak\erro.log
----以上脚本内容与set @erro_sql='set @erro_type=errono 001 & echo [email=%@erro_type%]%@erro_type%>>D:\07script\testdbbak\erro.log'[/email]
----意思相同,但是用脚本可以但用语句就不行,很多人都没办法,那为高手能解决?
set nocount on
--开启xp_cmdshell支持
exec sp_configure 'show advanced options', 1
reconfigure with override
exec sp_configure 'xp_cmdshell', 1
reconfigure with override
exec sp_configure 'show advanced options', 0
reconfigure with override
print char(13)+'------------------------'
--将报错信息输入到错误日志
exec xp_cmdshell @erro_sql
----以上脚本内容与set @erro_sql='set @erro_type=errono 001 & echo [email=%@erro_type%]%@erro_type%>>D:\07script\testdbbak\erro.log'[/email]
----意思相同,但是用脚本可以但用语句就不行,很多人都没办法,那为高手能解决?
回复

使用道具 举报

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

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行