Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

database attached is read only

I used the following the script to attach a database. But the database created is read only.
What modifications should I make in the script to make it read-write. Please help me.

USE [master] GO CREATE DATABASE [GemDatabase] ON  ( FILENAME = N'E:\Program Files (x86)\ICE Products\ICEConnect200\New Database\GemDatabase.mdf' ), ( FILENAME = N'E:\Program Files (x86)\ICE Products\ICEConnect200\New Database\GemDatabase_log.ldf' )  FOR ATTACH GO if not exists (select name from master.sys.databases sd where name = N'GemDatabase' and SUSER_SNAME(sd.owner_sid) = SUSER_SNAME() ) EXEC [GemDatabase].dbo.sp_changedbowner @loginame=N'sa', @map=false GO 
like image 328
Maanu Avatar asked May 19 '11 07:05

Maanu


People also ask

Why is my SQL database read only?

Occasionally, after moving your SQL Database to a new Drive, SQL updates the permissions to be Read Only for the database. You can update this in SSMS (Microsoft SQL Server Management Studios) on the server. After moving your SQL Server, the Properties may update to be Read Only.

How can I tell if a database is read only?

databases . SELECT name, is_read_only FROM sys. databases WHERE name = 'MyDBNAme' GO --returns 1 in is_read_only when database is set to read-only mode.

How do I remove read only from MDF?

mdf file resides is not read only. If it is, un-check that option and make sure it reflects to folders and files within that folder. Once that is done, Open Management Studio, in the Object Explorer right click on the Database which is read only and select Properties.


1 Answers

First make sure that the folder in which your .mdf file resides is not read only. If it is, un-check that option and make sure it reflects to folders and files within that folder.

Once that is done, Open Management Studio, in the Object Explorer right click on the Database which is read only and select Properties. In the Options Menu, check that the Read-Only property is false.

enter image description here

like image 198
Varun Rathore Avatar answered Oct 12 '22 03:10

Varun Rathore