When creating a T-SQL step in a SQL Server Agent job, is there a way to pull from a database on a different server? For example, I'd like to query different database job histories across all of the various servers. Possible?

link|improve this question
feedback

3 Answers

up vote 2 down vote accepted

Besides running queries via linked servers there is also the whole 'multiserver' concept in SQL Agent. See:

You should also look into Centralised Managed Servers in SSMS:

link|improve this answer
feedback

You can only access an external server if it is a linked server in the server that you are running the query from. After adding the server as a linked server access objects on that server with the full name -- [servername].[database].[dbo].[object].

link|improve this answer
feedback

You can issue queries against linked servers with the OPENQUERY function. See here.

If you'd rather do it without a linked server, with an ad-hoc connection (specifying the connect string in the function call), use OPENROWSET. See here.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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