Solved

Record open by another user

Posted on 2016-10-03
6
66 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 48

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 48

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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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 48

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

820 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