Solved

Record open by another user

Posted on 2016-10-03
6
41 Views
Last Modified: 2016-10-03
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
Comment
Question by:RIAS
  • 3
  • 3
6 Comments
 
LVL 45

Assisted Solution

by:Vitor Montalvão
Vitor Montalvão earned 500 total points
ID: 41826359
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
 

Author Comment

by:RIAS
ID: 41826363
And what happend if two users are trying to add the same new record at same time ?
Can anything be done about that
0
 
LVL 45

Expert Comment

by:Vitor Montalvão
ID: 41826365
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:RIAS
ID: 41826377
So it is all handled by default sql server setting.No settings are required from my side?
0
 
LVL 45

Accepted Solution

by:
Vitor Montalvão earned 500 total points
ID: 41826413
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
 

Author Closing Comment

by:RIAS
ID: 41826424
Very clear and brilliant solution provided as always!
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now