So essentially my query is currently grabbing data from two different linked servers which is causing the query to run at a unbelievable slow time (both are slow servers and need to be replaced). Normally for queries if they all grabbing information from the same database I'd do something like this:
EXEC (@SQL) AT [SERVER]
The server above that I execute it at makes the query run blazing fast. Like I'm talking a 43 minutes query running in 14 seconds. Not sure exactly why but was told it may have better indexing (not quite sure how indexing works that much).
But I can't do this anymore since one of the database's doesn't exist within this server. And no, I can't copy the database over to the other server.
Can anyone give me any advice on what to replace the server prefix with or what's a good way to approach this?
Example:
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SELECT
-- Several Columns.
FROM
dbo.mem m
INNER JOIN [SERVER1].DATABASE1.dbo.TABLE1 c on c.COL1 = m.COL1
INNER JOIN [SERVER2].DATABASE2.dbo.TABLE2 BM ON BM.COL1= c.COL1
WHERE
-- CONDITIONS
GO