通过SQL的master数据库中的sysdatabases和sysaltfiles两张表查出
数据库名,数据库mdf存放路径,数据库ldf路径
select [sysdatabases].[name],[sysdatabases].[filename] as
datafile,[sysaltfiles].filename as logfile from sysdatabases
inner join sysaltfiles ON sysdatabases.dbid = sysaltfiles.dbid
where sysaltfiles.fileid = '2'
inner join sysaltfiles ON sysdatabases.dbid = sysaltfiles.dbid
where sysaltfiles.fileid = '2'