Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Execute on a remote server

Author  Topic 

RyanAustin
Yak Posting Veteran

50 Posts

Posted - 2009-03-05 : 16:14:28
Is there a way that I can exec a command like xp_instance_regread on a remote server using a linked server? I need to run the xp to grad the default backup directory and it will not work.

ex. exec @returncode = master.dbo.xp_instance_regread N'hkey_local_machine',N'software\microsoft\mssqlserver\mssqlserver',N'backupdirectory', @path output, 'no_output' --> This runs fine on the local server but if I change it to start calling @strServerName (being the linked server) it fails.
ex. exec('exec '+@returncode+' = master.dbo.xp_instance_regread N''hkey_local_machine'',N''software\microsoft\mssqlserver\mssqlserver'',N''backupdirectory'', '+@path +'output, ''no_output''')
   

- Advertisement -