Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need to attach an MDF with faulty Log file

Status
Not open for further replies.

sab4you

IS-IT--Management
Jan 30, 2003
269
Using Windows 2000 and SQL 2000 I had a database on drive F: while the Log was on drive D:

Unfortunately Drive D: took a dump. In SQL Enterprise I took the database offline and detached it.

I cannot salvage the log file off drive d: so all I have is the MDF.

When I attempt to re-attach the database it always tells me the logfile on drive d:\ is bad and wont let it work.

I tried some stored procedure to add a single database but it also knew I had the log file and failed.

I am not very experienced with SQL, but I was hopeful you guys had some tips to salvage the database?
 
EXEC sp_attach_single_file_db @dbname = 'your _DB_name',
@physname = 'path\???.mdf'

the above command will creat a new log file with minimum size.

Then again execute following command

USE master
EXEC sp_detach_db 'your_DB_name', 'true'

Now you move your data and log file in specific locations (directorie or sub directorie) and then execute following command

EXEC sp_attach_db @dbname = 'your_DB_name',
@filename1 = 'd:\Path????\Data_filename.mdf',
@filename2 = 'd:\Path????\Log_filename.ldf'

Make sure you make full backup before above all commands
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top