如何在T-SQL中找到mdf / ldf位置?

时间:2014-02-13 08:42:54

标签: sql-server sql-server-2008

如何使用T-SQL在SQL2008中找到mdf / ldf位置?从“属性”屏幕开始,生命太短,容易出错。

2 个答案:

答案 0 :(得分:3)

SELECT   DB_NAME(database_id) AS DatabaseName
        ,Name AS Logical_Name
        ,Physical_Name
        ,(size*8)/1024 SizeMB
FROM   sys.master_files
WHERE  DB_NAME(database_id) = 'Your_database_Name'
GO

Use Database_Name
GO

SELECT  name
       ,type_desc
       ,physical_name
       ,(size*8)/1024 SizeMB
FROM   sys.database_files
GO

答案 1 :(得分:1)

试试这个:

select filename FROM sysfiles