Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

3 Answers 3

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

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

Your Answer

 
discard

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.