1

I'm try to figure how to create sql server stored procedure that when a condition is met executes an executable, with command line arguments, on a remote machine within the network. I could write my own little server application to handle the communication sent from the stored procedure for the executable, but I'm not certain if socket programming is a reasonable option with sql server. Any direction would be helpful.

1 Answer 1

1

You'd need some server-side application anyway, even if that application were SQL Server :)

Something like rsh might do - have your local SQL instance invoke xp_cmdshell with an rsh command (or a batch file), connecting to the remote server and executing the command.

If you have SQL on the remote machine, it'd be far easier; call a stored procedure on that machine from the local machine, and let that stored procedure do the work (might need fiddling with proxies and "execute as").

A third option would be to create a .NET stored procedure, and do your socket programming or remote invocation from there - it runs in-process, so you get similar same performance and security benefits you'd get from writing it in T-SQL rather than hopping out to a cmdshell with all the mess that entails.

3
  • I'm getting "can't establish connection" error messages. Do I need to configure some things on the host machine?
    – Kevin
    Jun 19, 2009 at 15:12
  • ignore my last comment, I'm doing something wrong. Let me keep trying
    – Kevin
    Jun 19, 2009 at 15:20
  • I got the rsh command to work. This is AWESOME. My other ideas would have involved much more work and a much slower process.
    – Kevin
    Jun 19, 2009 at 16:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.