I seem to be unique with this problem, because my Google-fu isn't showing this having come up before. The gist of the problem: linked server query actually pulls data from the primary server, assumedly because db/table name is same.
The setup: SQL Server 2005 on both server "DW" and server "RPT". Both are using named instances.
The query is run from DW, from within database DW. A linked server RPT\INSTANCE has been set up, and works.
SELECT COUNT(*) FROM MYTABLE
returns 450, which is correctly the number of rows in database DW on server DW for MyTable.
SELECT COUNT(*) FROM OTHERDB.DBO.MYTABLE
returns 420, which is correctly the number of rows in database OTHERDB on the same server.
SELECT COUNT(*) FROM [RPT\INSTANCE].OTHERDB.DBO.MYTABLE
returns 420, which is incorrect.
After much trial-and-error (and with real data pulls, not just counts), I've found that even though I've specified [RPT\INSTANCE], and the query runs without error, I am getting results from the same database name, same table name on the primary server.
I've dropped and rebuilt the linked server, tried synonyms; no joy.
Renaming one of the databases is not desirable, as it will break quite a few things. Any suggestions on what else to check for/try would be appreciated.
--------------
SQLS metasearch
The setup: SQL Server 2005 on both server "DW" and server "RPT". Both are using named instances.
The query is run from DW, from within database DW. A linked server RPT\INSTANCE has been set up, and works.
SELECT COUNT(*) FROM MYTABLE
returns 450, which is correctly the number of rows in database DW on server DW for MyTable.
SELECT COUNT(*) FROM OTHERDB.DBO.MYTABLE
returns 420, which is correctly the number of rows in database OTHERDB on the same server.
SELECT COUNT(*) FROM [RPT\INSTANCE].OTHERDB.DBO.MYTABLE
returns 420, which is incorrect.
After much trial-and-error (and with real data pulls, not just counts), I've found that even though I've specified [RPT\INSTANCE], and the query runs without error, I am getting results from the same database name, same table name on the primary server.
I've dropped and rebuilt the linked server, tried synonyms; no joy.
Renaming one of the databases is not desirable, as it will break quite a few things. Any suggestions on what else to check for/try would be appreciated.
--------------
SQLS metasearch