October 18, 2007 at 9:58 am
I need to determine the logical names for the data and log files for a given database. The following code works for 2K5, but I need a 2K counterpart. This may not be as bullet-proof as it needs to be, but here's what I have...
SELECT
name
FROM
sys.master_files
WHERE
database_id = DB_ID('dbname goes here')
AND
(
CHARINDEX('.MDF', LOWER(physical_name)) > 0
OR
CHARINDEX('.LDF', LOWER(physical_name)) > 0
)
October 18, 2007 at 10:18 am
try the sysfiles table for the database you are concerned with.
October 18, 2007 at 10:29 am
SELECT
name
FROM
master.dbo.sysfiles
only returns "master" and "mastlog" 🙁
October 18, 2007 at 2:30 pm
[font="Courier New"]USE MyDB
SELECT name, filename FROM dbo.sysfiles[/font]
Best wishes,
Phil Factor
October 18, 2007 at 6:24 pm
sp_HelpFile
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply