<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jeremy Smyth's Blog &#187; Windows</title>
	<atom:link href="http://jeremysmyth.com/category/windows/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeremysmyth.com</link>
	<description></description>
	<lastBuildDate>Sun, 04 Jul 2010 07:10:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Running a command on a remote server with SQL Server</title>
		<link>http://jeremysmyth.com/2009/06/20/running-a-command-on-a-remote-server-with-sql-server/</link>
		<comments>http://jeremysmyth.com/2009/06/20/running-a-command-on-a-remote-server-with-sql-server/#comments</comments>
		<pubDate>Sat, 20 Jun 2009 18:17:13 +0000</pubDate>
		<dc:creator>Jeremy Smyth</dc:creator>
				<category><![CDATA[Windows]]></category>
		<category><![CDATA[rsh]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://jeremysmyth.com/?p=38</guid>
		<description><![CDATA[Another StackOverflow question: How do I run an OS command on a remote server, from within SQL Server? I answered as follows.
Something like rsh might do &#8211; 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 [...]]]></description>
			<content:encoded><![CDATA[<p>Another StackOverflow question: How do I run an OS command on a remote server, from within SQL Server? I answered as follows.</p>
<p>Something like rsh might do &#8211; 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.</p>
<p>If you have SQL on the remote machine, it&#8217;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 proxy accounts and &#8220;execute as&#8221;).</p>
<p>A third option would be to create a .NET stored procedure, and do your socket programming or remote invocation from there &#8211; it runs in-process, so you get similar same performance and security benefits you&#8217;d get from writing it in T-SQL rather than hopping out to a cmdshell with all the mess that entails.</p>
<p>The rsh solution <a href="http://stackoverflow.com/questions/1017992/sql-server-2005-executing-exe-on-remote-machine-or-connect-to-server-application/1018059#1018059">won the day</a>.</p>
<p>Having said that, the rsh solution is not tied to SQL Server &mdash; rsh can be invoked from anything capable of running shell commands locally, even a batch file, or a Perl script.</p>
<p>Rsh is a feature Microsoft added to Windows a few versions ago, although a variety of it has been available in resource kits since NT 4.0. In simplest terms, it provides a remote command line, not unlike telnetting into a Unix server, only you get the Windows CMD prompt. Rsh allows the invoker to invoke a single command remotely, using command-line options, and without the need to write any further server-side code. This makes it suited to the quick-and-dirty route taken by the recipient of the above answer.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeremysmyth.com/2009/06/20/running-a-command-on-a-remote-server-with-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
