-3

Is there a query in T-SQL that pulls out the location of all databases within a server in the network (not the local drive).

I had a look at this example SQL Server - get all databases with MDF and LDF File Location .But, it didn't seem to work, I am guessing this is due to the location of this server which is not local.

Community
  • 1
  • 1
ArsedianIvan
  • 369
  • 2
  • 6
  • 20
  • the answer in your linked question is the best you can get since SQL server only "knows" the file location in its own environment you can see the same info looking at the `properties/files` menu of each DB – Smog Mar 11 '15 at 23:06
  • possible duplicate of [SQL Server - get all databases with MDF and LDF File Location](http://stackoverflow.com/questions/27057000/sql-server-get-all-databases-with-mdf-and-ldf-file-location) – void Mar 11 '15 at 23:31
  • No it clearly is not Farheg. Read it before commenting – ArsedianIvan Mar 12 '15 at 03:53
  • 1
    My understanding of the your statement 'didn't seem to work'...didn't seem to work. What were you expecting and what did you get? – Nick.Mc Mar 12 '15 at 04:03
  • Nothing happened, it produced a blank table. – ArsedianIvan Mar 12 '15 at 22:38

1 Answers1

0

The linked answer works but you must have enough permissions to view the results.

From sys.databases:

If the caller of sys.databases is not the owner of the database and the database is not master or tempdb, the minimum permissions required to see the corresponding row are ALTER ANY DATABASE or VIEW ANY DATABASE server-level permission, or CREATE DATABASE permission in the master database. The database to which the caller is connected can always be viewed in sys.databases.

From sys.master_files:

The minimum permissions that are required to see the corresponding row are CREATE DATABASE, ALTER ANY DATABASE, or VIEW ANY DEFINITION.

Andriy M
  • 76,112
  • 17
  • 94
  • 154