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
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With