SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

ycr1988
Starting Member

India
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.

Regards,
Chakradhar.


Ycr

James K
Flowing Fount of Yak Knowledge

3724 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 (http://msdn.microsoft.com/en-us/library/ms345598.aspx), 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. http://msdn.microsoft.com/en-us/library/ms175519(v=sql.105).aspx
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.05 seconds. Powered By: Snitz Forums 2000