mercredi 29 juin 2016

Referencing another table in T-SQL not working

I've been running a query on a large number of servers, and on just three of them (SQL2000, SQL2005 AND SQL2008) the query fails. I've boiled it down to referencing a table in another DB.

SELECT * FROM MASTER.dbo.syslogins AS syslogins

Which works on 99% of the servers, but on the three gives:

Invalid object name 'MASTER.dbo.syslogins'

If I switch to the master DB and run

SELECT * FROM dbo.syslogins AS syslogins

Then it works. I've also checked I have permissions by running

SELECT IS_SRVROLEMEMBER('sysadmin');

Which returns a 1. So why does referencing the MASTER.dbo.syslogins table fail?

Aucun commentaire:

Enregistrer un commentaire