Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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:

share|improve this answer

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].

share|improve this answer

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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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