SQL query on multiple SQL servers
I have 2 SQL servers. I need a SQL query that can join two tables that are on two different servers.
how
SELECT *
FROM Server1.Db1.dbo.table1 A
INNER JOIN Server2.Db1.dbo.table2 B ON A.Id = B.Id
and I have no server names, I use the servers IP instead. Do I need to enable these SQL servers as a linked server in order to allow such cross-server queries?
+3
Andy T
source
to share
2 answers
You can navigate to Linked Servers with sp_addlinkedserver
. After that, you can request your details, as you mentioned,
SELECT *
FROM [Db1].[dbo].table1 A
INNER JOIN [Server2].[Db1].[dbo].table2 B
ON A.Id = B.Id
+7
Nadeem_MK
source
to share
Yes, add one option as a linker. You can also join a remote table using [ip address] .dbname.dbo.table s name well.
+1
Hlin
source
to share