谁能说出"EXEC xp_cmdshell(sql脚本)"是否可以应该在ssmse2k8内部工作吗? [英] Can anyone say whether "EXEC xp_cmdshell (sql script)" is supposed to work from within ssmse2k8?

查看:113
本文介绍了谁能说出"EXEC xp_cmdshell(sql脚本)"是否可以应该在ssmse2k8内部工作吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试通过脚本编辑器作为订单项执行变量,则此设置为文件名的变量将不起作用.

This setup of a variable for use as a filename doesn''t hold any water if I try to execute it from the script editor as a line item.

DECLARE @scriptfile varchar(4000)
SET @scriptfile = 'c:\users\fith.sql'
EXECUTE xp_cmdshell @scriptfile



[EXEC sp_configure``xp_cmdshell'',1 ...已完成]

该接口进入长时间执行等待阶段,从此阶段它不再返回,或者在消息栏中在那里成功完成,但是实际上并没有根据代码更改数据库中的任何内容.

另一个开关?

WSServer2K8 R2
SSMSE 64位



[EXEC sp_configure ''xp_cmdshell'', 1 ... has been done]

The interface enters either a long execute wait phase out of which it never returns or it completes successfully there at the message bar but doesn''t actually change anything in the database per the code.

Another switch?

WSServer2K8 R2
SSMSE 64 bit

推荐答案

xp_cmdshell执行OS命令,因此,基本上,如果您使用xp_cmdshell执行SQL脚本,它将尝试在命令提示符下执行SQL语句. />
如果要运行SQL脚本,请尝试执行 SQLCMD [
The xp_cmdshell executes an OS command so basically if you execute a SQL script using xp_cmdshell, it tries to execute the SQL statements in command prompt.

If you want to run a SQL script, try executing SQLCMD[^] using xp_cmdshell and give the sql script to sqlcmd as a parameter.

So something like:
SET @scriptfile = 'sqlcmd -i c:\users\fith.sql' -S... -U...


这篇关于谁能说出"EXEC xp_cmdshell(sql脚本)"是否可以应该在ssmse2k8内部工作吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆