开发者

call xp_cmdshell with xml parameter

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开发者_StackOverflow社区.


The answer is that script:

EXEC master.dbo.xp_cmdshell '""D:\ConsoleTest.exe" "<Messages><msg>My message</msg></Messages>""'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜