attaching DB without .ldf file ?
hi !!
I want to attach database to SQL Server, but I'hv only .mdf file.
I lost .ldf file, how should i attach this DB to server ?
Thanks
SP
I want to attach database to SQL Server, but I'hv only .mdf file.
I lost .ldf file, how should i attach this DB to server ?
Thanks
SP
Take a look at sp_attach_single_file_db (or CREATE DATABASE ... FOR ATTACH in SQL Server 2005).
Was the database shutdown cleanly?
You can attach a database without the logfile by attaching, then clicking the logfile location, and click the remove button. After you click OK a new logfile will be created for your database, like so:
http://img.photobucket.com/albums/v472/Schmedrick/attach.gif
hi !!
thanks for reply.
I tried both the solution , but i am getting error -
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL\data\Settings_Log.LDF" may be incorrect.
The log cannot be rebuilt because the database was not cleanly shut down
I don't hv LOG file of database , only hv mdf file.
Is there any other solution
SPD
If the database wsa not cleanly shut down, and you do not have the log file, you will have some lost data and possible inconsistencies.
The best method to use depends on which version of SQL Server you're running. If you can let us know that, we'll take the next step.
I'm having a similar problem. I'm using sql server 2000 and my database has 2 log files. I lost one and when I trying attach without log file I got error !
Regards,
Alexandre A.
ok - in that case, becase your database wasn't cleanly shutdown you'll need to use the last resort (assuming you're using SQL Server 2005)
Your database will be available again but you'll have lost data and the data won't be transactionally consistent - see the following blog posts:
If you're on SQL Server 2000, you can still do this but you'll need to use the undocumented DBCC REBUILD_LOG at your own risk. If you're unsure about any of this, you should contact Product Support to help you.
Thanks
Paul Randal - MSFT wrote:
ok - in that case, becase your database wasn't cleanly shutdown you'll need to use the last resort (assuming you're using SQL Server 2005)
- create a database of equal size to the one you're trying to attach
- shutdown the server
- swap in the old mdf file
- bring up the server and let the database attempt to be recovered and then go into suspect mode
- put the database into emergency mode with ALTER DATABASE
- run DBCC CHECKDB (dbname, REPAIR_ALLOW_DATA_LOSS) which will rebuild the log and run full repair
Your database will be available again but you'll have lost data and the data won't be transactionally consistent - see the following blog posts:
- https://blogs.msdn.com/sqlserverstorageengine/archive/2006/06/15/632398.aspx
- https://blogs.msdn.com/sqlserverstorageengine/archive/2006/06/16/633645.aspx
- https://blogs.msdn.com/sqlserverstorageengine/archive/2006/06/18/636105.aspx
If you're on SQL Server 2000, you can still do this but you'll need to use the undocumented DBCC REBUILD_LOG at your own risk. If you're unsure about any of this, you should contact Product Support to help you.
Thanks
When I started SQL Server and tried following code:
Use master go sp_configure 'allow updates', 1 reconfigure with override go sp_dboption 'MainBase', 'single_user', 'true' go alter database MainBase set EMERGENCY go DBCC CHECKDB('MainBase', REPAIR_ALLOW_DATA_LOSS) Go
I got an error:
Msg 922, Level 14, State 1, Line 1
Database 'MainBase' is being recovered. Waiting until recovery is finished.
What should I do?
just wait for sometime as the database is currently recovering.i.e its rolling forward the committed transactions and rolling back the uncommited trans....it will recover soon
I was waiting for 11 hours but nothing happened. I think there is no point in waiting becouse the database isn't really recovering.
Is there any possibility to change sysdatabases.status = 32768 (emergency mode)? Currently sysdatabases.status = 70656
i dont know whether you can change the db into emergency mode coz its currently recovering,anyways try
alter database dbname set emergency
if its not working try to bring the db online by,
restore database dbname with recovery but i am not sure if this works?...........cool
No. It doesn't work. I can swich th status between OFFLINE and
RECOVERY PENDING =((
May be I can detach it and try to attach using MSSQL2000 instead 2005?