I have an MDF file and no LDF files for a database created in MS SQL Server 2005. When I try to attach the MDF file to a different SQL Server, I get the following error messa
Found a another way that works completely:
I got a working database after trying all of the above that failed for me.
I hope it is easy to do so,
Execute the following query
sp_attach_single_file_db @dbname='dbname',@physname='C:\Database\dbname.MDF'
Where dbname
is you want to show in Object Explorer, where @physname
is the local filepath location of your mdf file.
Hope it will help someone, i done by above, got both structure and also data.
Tested in Sql Server 2000 and 2008. In Sql Server 2000 it is not working, but works perfectly in 2008.
have you tried to ignore the ldf and just attach the mdf:
sp_attach_single_file_db [ @dbname = ] 'dbname' , [ @physname = ] 'physical_name'
i don't know exactly what will happen to your open transactions (probably just lost), but it might get your data back online.
-don