Click here to Skip to main content
16,017,200 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
hI,

I have AdventureWorks2008R2_Data.mdf file. and I want to attach it to may Sql Server 2008R2 database. I don't have its ldf file though. I run the following script..

SQL
USE [master]
CREATE DATABASE Adventure ON
(FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER1\MSSQL\DATA\AdventureWorks2008R2_Data.mdf')
FOR ATTACH_REBUILD_LOG
GO 


It gives me following message with an error...

SQL
Msg 5120, Level 16, State 101, Line 2
Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER1\MSSQL\DATA\TestDb_log.LDF". Operating system error 32: "32(The process cannot access the file because it is being used by another process.)".
File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER1\MSSQL\DATA\TestDb_log.LDF" may be incorrect.
New log file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER1\MSSQL\DATA\Adventure_log.LDF' was created.


How to get rid of this???
Posted

1 solution

Why not get a fresh copy from Microsoft SQL Server Community Projects & Samples[^]

Anyhow the error is a bit confusing. You try to attach primary file AdventureWorks2008R2_Data.mdf but the error message implies that SQL Server cannot find file TestDb_log.LDF. That doesn't seem the be the default log file of the AdventureWorks database. Are you actually trying to attach a mdf file that is already in use by Sql Server?
 
Share this answer
 
Comments
comred 23-May-12 3:17am    
yes..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900