使用 xml 参数调用 xp_cmdshell
创建的控制台应用程序有两个参数:一个是像“send”这样的命令,第二个是像 "
“
。
问题是如何使用 T-SQL 调用上面提到的控制台应用程序存储过程 xp_cmdshell。主要问题是如何用xml发送参数。例如,上面提到的控制台应用程序,可以使用以下表达式执行:
"c:\consoleapp.exe" send "<Messages><msg>My message</msg></Messages>"
该表达式可以从控制台毫无问题地执行,但不能使用 xp_cmdshell。 在 xp_cmdshell 的情况下,sql server 输出将返回:
< was unexpected at this time.
It was created console application that has two param: one is a command like "send" and second is a xml string like "<Messages><msg>My message</msg></Messages>"
. Console application will return something like: "<Messages><msg>Handled message</msg></Messages>"
after execution.
The question is how to call stored procedure xp_cmdshell mentioned above console application using T-SQL. The main problem is how to send parameter with xml. For example, mentioned above console application, can be executed with this expression:
"c:\consoleapp.exe" send "<Messages><msg>My message</msg></Messages>"
This expression can be executed without problem from console, but not with xp_cmdshell.
In the case of xp_cmdshell sql server outut will return:
< was unexpected at this time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
答案是该脚本:
The answer is that script: