HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Querying sys.master_files over a linked server

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
master_filesqueryingsysserverlinkedover

Problem

Querying sys.master_files through a linked server, I get no results.

Why? How do I work around this issue?

Solution

This approach works fine for me:

SELECT * FROM [linked_server_name].master.sys.master_files;


What you need to be sure of is that the linked server is running in the context of a user who has enough privileges to see the contents of the DMV. You can check who you're executing as using:

EXEC [linked server name].master.sys.sp_executesql N'SELECT SUSER_SNAME(),
   ORIGINAL_LOGIN();';

Code Snippets

SELECT * FROM [linked_server_name].master.sys.master_files;
EXEC [linked server name].master.sys.sp_executesql N'SELECT SUSER_SNAME(),
   ORIGINAL_LOGIN();';

Context

StackExchange Database Administrators Q#112972, answer score: 7

Revisions (0)

No revisions yet.