I am running a query from a utilities database, and I want to query a vendor database we have.
I am running the query below from inside the vendor database and it works as expected.
SELECT * FROM
sys.dm_db_index_usage_stats xINNER JOIN sys.indexes iON x.object_id = i.object_idAND x.index_id = i.index_id
Then when I change to use the Utilities database and prefix the tables in the above query with VendorDatabase.
I get totally different results.
I'm missing something obvious here I assume? I want to run this from a stored procedure in the utilities database.
SELECT * FROM VendorDB.sys.dm_db_index_usage_stats x
INNER JOIN VendorDB.sys.indexes i
ON x.object_id = i.object_id
AND x.index_id = i.index_id