Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Reg:Sql server database readonly
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

3 Posts

Posted - 06/26/2013 :  10:10:37  Show Profile  Reply with Quote
Hi Experts,

I have a requirement like the below steps,
1)I want to lock the database (as it readonly).
2)I will add tables ,add columns to existing tables or make some columns contains default values.
3)Then i want release database.



James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 06/26/2013 :  10:17:40  Show Profile  Reply with Quote
I can think of two ways, there may be a better way perhpas:

1. Put the database into single user mode (, make your changes, and then set it back to multi-user mode. The disdvantage is that other users won't even be able to connect to the database during that period, and it will require disconnecting any others who are already connected. So probably not a good solution.

2. Write your update queries, and at the beginning of the query, take an exclusive lock on all the tables that you plan to touch, and release the lock at the end of the query. If the queries are of short duration, the clients should not even notice that you locked them. The disdvantage is that you will need to be careful to make sure that you lockdown everything you want to lockdown.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000