Tuesday, March 20, 2012

Associating mdf and ldf files to databases

Is there some sort of command that can tell me which mdf and ldf files are associated to which databases?

Thanks,
Ninel

There are many ways to get the information depending on the version of SQL Server. You can query the following tables/views:

master.dbo.sysaltfiles (SQL Server 2000)

sys.master_files (SQL Server 2005)

To look at individual databases only, you can use the system stored procedure "sp_helpdb" in any version of SQL Server.

No comments:

Post a Comment