I need a T-SQL query for a list of all databases in SQL Server 2008 showing
我需要一个T-SQL查询来显示SQL Server 2008中所有数据库的列表
- the name of the database and
- 数据库的名称和
- the location of the
.mdf
and.ldf
files. - .mdf和.ldf文件的位置。
3 个解决方案
#1
31
SELECT
db.name AS DBName,
type_desc AS FileType,
Physical_Name AS Location
FROM
sys.master_files mf
INNER JOIN
sys.databases db ON db.database_id = mf.database_id
#2
6
select
d.name as 'database',
mdf.physical_name as 'mdf_file',
ldf.physical_name as 'log_file'
from sys.databases d
inner join sys.master_files mdf on
d.database_id = mdf.database_id and mdf.[type] = 0
inner join sys.master_files ldf on
d.database_id = ldf.database_id and ldf.[type] = 1
#3
-3
Try this query:
试试这个查询:
SELECT name [Database Name], physical_name [File Location],size *(8.0 / 1024) /1024 [Size in GBs]
FROM sys.master_files
#1
31
SELECT
db.name AS DBName,
type_desc AS FileType,
Physical_Name AS Location
FROM
sys.master_files mf
INNER JOIN
sys.databases db ON db.database_id = mf.database_id
#2
6
select
d.name as 'database',
mdf.physical_name as 'mdf_file',
ldf.physical_name as 'log_file'
from sys.databases d
inner join sys.master_files mdf on
d.database_id = mdf.database_id and mdf.[type] = 0
inner join sys.master_files ldf on
d.database_id = ldf.database_id and ldf.[type] = 1
#3
-3
Try this query:
试试这个查询:
SELECT name [Database Name], physical_name [File Location],size *(8.0 / 1024) /1024 [Size in GBs]
FROM sys.master_files