Below SQL Script will help you to find current location of Data and Log File of the Database. It shows the file location of every database on a SQL Server instance.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
SELECT [Database] as [Database Name], [1] as MDF_File_Location, [2] as Log_File_Location FROM ( SELECT [Database], [1], [2] FROM ( SELECT d.name [Database], mf.file_id, mf.physical_name AS [Path] FROM sys.master_files mf INNER JOIN sys.databases d ON d.database_id = mf.database_id ) AS st PIVOT ( MAX([Path]) FOR file_id IN ([1], [2]) ) AS PT ) a |
Leave a Comment