views:

334

answers:

1

Hello, 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  A: 

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.

Jeremy Smyth
I'm getting "can't establish connection" error messages. Do I need to configure some things on the host machine?
Kevin
ignore my last comment, I'm doing something wrong. Let me keep trying
Kevin
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