Home > Ask the SQL Server Experts > Archive: Backup and Recovery Questions & Answers > Attaching a database that has missing log file
Ask The SQL Server Expert: Questions & Answers
EMAIL THIS

Attaching a database that has missing log file

Greg Robidoux EXPERT RESPONSE FROM: Greg Robidoux

Pose a Question
Other SQL Server Categories
Meet all SQL Server Experts
Become an Expert for this site


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


>
QUESTION POSED ON: 17 August 2004
In SQL Server 2000, I have copied the data file (*.mdf) but was not able to copy the log file (*ldf). I am trying now to attach the database to another server, but it is returning an error message that the log file is different. How can I attach a database that has a missing or invalid log file?

>

You are in luck as long as the sp_detach_db was executed properly. If so, use the sp_attach_single_file_db command to attach a database with a single data file (*.mdf). When you use this command, SQL Server will create a log file and attempt to resolve any data related discrepancies. The syntax for this command would be:

 USE Tempdb
GO
EXEC master.dbo.sp_attach_single_file_db @dbname = 'DatabaseName', 
@physname = 'D:Program FilesMicrosoft SQL ServerMSSQLDataDatabaseName.mdf'
 GO
Based on the circumstances, it may be beneficial to ensure that the database does not have any consistency or allocation issues by executing the following commands:


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Archive: Backup and Recovery
Synchronize databases on two separate active servers
Back up tables from SQL Server 2005 database to a file
Restore SQL Server 2000 backups in SQL Server 2005
Restoring a SQL Server database with a corrupt data file
SQL Server error message: "Server out of memory"
Configure log shipping between SQL Server 2000 and 2005
Restoring from msdb with only .mdf and .ldf files
Extended stored procedure to back up databases
Change tempdb from 'C' drive
Back up stored procedure only

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



SQL Solutions - SQL Database Design
HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersIT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 2005 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts