Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 128
  • Last Modified:

Record open by another user

Hello,
Is there any way we can Check whether in sql server the same record is opened by another user on another machine ?


Cheers
0
RIAS
Asked:
RIAS
  • 3
  • 3
2 Solutions
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
Is there any way we can Check whether in sql server the same record is opened by another user on another machine ?
As far as I know you can't. Only way that I can think of is to have a column set to true every time somebody open the record and set it to false when nobody else has the record opened.
Ofc that if the record is locked then a SQL error will be raised when some other process is trying to read the record.
0
 
RIASAuthor Commented:
And what happend if two users are trying to add the same new record at same time ?
Can anything be done about that
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
And what happend if two users are trying to add the same new record at same time ?
It depends on your Primary Key definition and the existence of any Unique Index. If you have both or at least one of kind of those indexes then it will raise an error and the second record will be rolled back.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
RIASAuthor Commented:
So it is all handled by default sql server setting.No settings are required from my side?
0
 
Vitor MontalvãoMSSQL Senior EngineerCommented:
No settings are required from my side?
If you have corrected set the Primary keys and unique keys then the database engine will raise the errors when a duplicate records is being tried to be inserted.
0
 
RIASAuthor Commented:
Very clear and brilliant solution provided as always!
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now