April 4, 2006 at 10:09 am
I have a sp that will accept a database name as a variable. I need to use that name to get the .mdf and .ldf file names and paths for that database.
Does anyone have a solution for this?
I will then use those filenames and paths to perform a detach and subsequent attach of the database.
Thanks.
Paul
April 4, 2006 at 10:16 am
April 4, 2006 at 10:25 am
What is BOL?
Will that get around creating dynamic sql based on the database name passed in to the sp?
Thanks,
Paul
April 4, 2006 at 10:28 am
Books On-Line (SQL Server Help files). Yes, you will be able to use the sysfiles table in dynamic SQL.
April 5, 2006 at 1:40 am
You can get the file name from the SYSdatabases table in master...
USE MASTER
SELECT filename FROM sysdatabases
WHERE name = 'pubs'
returns....
filename
---------------------------------
c:\sql\data\MSSQL\data\pubs.mdf
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply