Monday, July 7, 2014

T-SQL: MDF files in use

List the MDF file for every database in SQL Instance

declare @files table (
    db_name sysname,
    physical_name nvarchar(260)
)

insert into @files
    exec sp_MSforeachdb 'select "?", physical_name from ?.sys.database_files'

select db_name, physical_name 
    from @files


No comments:

Post a Comment