Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect to another SQL Server via SQL Query?

Tags:

sql

sql-server

Is it possible to connect to another SQL Server using a SQL query (so that one can also run queries on that server and use the result set in current server). If not, then why ?

like image 405
sequel.learner Avatar asked May 13 '13 10:05

sequel.learner


1 Answers

Yes, you can accomplish connecting to another SQL Server by using a Linked Server, or you can query through servers by using openquery:

SELECT * FROM openquery([aa-db-dev01], 'Select * from TestDB.dbo.users')

Querying a linked sql server

like image 175
Ruchan Avatar answered Oct 15 '22 10:10

Ruchan