|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, February 06, 2006 3:10 AM
Points: 2,
Visits: 1
|
|
Hi, our forum server suffered a catastrophic failure, which included the RAID failing too. I only have the mdf file, no ldf file. I did not unmount the db, or do a single file unmount. I've tried a few things to reattach it, but no joy. Any ideas would be appreciated. Thanks
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, March 15, 2010 10:58 AM
Points: 1,279,
Visits: 574
|
|
Hello Howard, Yes, you can attach a database with .mdf file but you will loose all the transactions, which have not been committed to the database. SQL Server will create a new .ldf file when you attach a database with a single file (.mdf). Syntax for attaching the single file: sp_attach_single_file_db [ @dbname = ] 'dbname' , [ @physname = ] 'physical_name' Thanks and have a nice day!!!
Lucky
|
|
|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Monday, February 06, 2006 3:10 AM
Points: 2,
Visits: 1
|
|
I tried that already with: EXEC sp_attach_single_file_db @dbname = 'koiforum', @physname = 'C:\Program Files\Microsoft SQL Server\MSSQL$LISTSERVER\data\koiforum_data.mdf' I get this error: Server: Msg 1813, Level 16, State 2, Line 1 Could not open new database 'koiforum'. CREATE DATABASE is aborted. Device activation error. The physical file name 'C:\Program Files\Microsoft SQL Server\MSSQL$LISTSERVER\data\KoiForum_Log.LDF' may be incorrect. Any ideas? Thanks
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, March 15, 2010 10:58 AM
Points: 1,279,
Visits: 574
|
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Friday, March 12, 2010 7:51 AM
Points: 97,
Visits: 36
|
|
This is the syntax that I use to attach a DB with only a MDF file:
Exec sp_attach_single_file_db DB_Name, 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\DB_Name_Data.MDF' Just change the highlighted portions. Matt
|
|
|
|
|
SSC Journeyman
      
Group: General Forum Members
Last Login: Wednesday, September 24, 2008 4:22 AM
Points: 90,
Visits: 4
|
|
If your database was not detached using sp_detach_db or your server was not shutted down cleanly you CAN'T use sp_atach_single_file_db.
Still, there is a workarround on this. I did use once the "dbcc rebuild_log" command to rebuild the ldf file, but my database become inconsistent. But I managed to copy most of my important data. If your data was so important you should had a backup plan for it.
|
|
|
|