Link to home
Start Free TrialLog in
Avatar of stephenlecomptejr
stephenlecomptejrFlag for United States of America

asked on

Can you lock an entire table in SQL Server while two people are in it and then when one person is in it unlock that entire table?

If someone is editing data belonging to one table and another comes along and starts to edit other data belonging to that same table - what I would like to do is lock it read only for the second user - where he/she cannot change it - sort of what Excel does when two people open the same document - is that possible?    Then if the first user leaves - the locking is removed for the second user - where he/she can change it?

Sure there is a lot online for record-row level locking, column locking would slow performance and then you get into user-permisions.  But this is special to where you want the locking to occur only on the second user (or third, fourth) temporarily and return when there is one user only accessing the table.

Second question - should this not be done at database level but merely only software front-end?
ASKER CERTIFIED SOLUTION
Avatar of wdosanjos
wdosanjos
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stephenlecomptejr

ASKER

"This technique again requires checking, of the control table whenever an update is attempted."

Is this done as a trigger in SQL server or done within the front-end software accessing sql server?
Front-End - it is application logic.