2

I want to attach a DB to SQL Server. I have the mdf files for it but those are in read-only state. Also the LDF file is not present. I use the following command to attach the DB.

Create database TrackData on (Filename = N'F:\Data\Bill_Data.mdf') FOR ATTACH_REBUILD_LOG 

but i get the following error.

Msg 3415, Level 16, State 3, Line 1
Database 'Bill_Data' cannot be upgraded because it is read-only or has read-only files. Make the database or files writeable, and rerun recovery.
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'Bill_Data'. CREATE DATABASE is aborted.

I know that it might not be possible to recover the Database in this case as MDF file is in read-only state. Also I do not have a backup of database. But still expecting any wild ideas that could help.

Madhur Maurya
  • 1,016
  • 4
  • 19
  • 42
  • 1
    There would appear to be [no way around not using the LDF file](http://dba.stackexchange.com/questions/63255/database-cannot-be-upgraded-because-it-is-read-only-or-has-read-only-files-make). Maybe you can get a hold of it somehow. – Tim Biegeleisen Sep 23 '16 at 07:38
  • @user2864740 to the same server version – Madhur Maurya Sep 23 '16 at 07:40
  • to attach a MDF file without a LDF you use `sp_attach_db`. What do you mean read only? Do you mean the files read only bit is flagged? Just unflag it first – Nick.Mc Sep 26 '16 at 05:31
  • Visit this link : Hope to help you – Novin.Kh Nov 28 '17 at 13:46

1 Answers1

0

Paste your .mdf file and ldf file in this directory - C:\Program Files\Microsoft SQL Server\MSSQL11.SS2012\MSSQL\DATA and make sure that the folder in which your .mdf file resides is not read only. please see this and this.

Community
  • 1
  • 1