Location of Data File Using T-SQL

Some times we need know the location of Data file of databases of sqlserver.Below script display the all the .mdf and .ldf files of sqlserver.

select Name as DataBasename,Physical_name as Location From master.sys.master_files

Advertisements