Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

SQL Server Lock Record or Multiple Records

Posted on 2008-11-14
2
Medium Priority
?
712 Views
Last Modified: 2012-05-05
I want to lock a single record in a specified table of my Database.
I want to excecute this lock to this record when my application starts and unlock when the application shutdown.
0
Comment
Question by:carmas123
2 Comments
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 22970404
why do you want to lock a record ?
locking of records is only done when you need to modify the data in that record

lets say you lock a record and the database on some server fails over to another database
your lock would be useless ...

care to explaing what you actually want ?
0
 
LVL 15

Accepted Solution

by:
mikelittlewood earned 500 total points
ID: 22974080
You could query the single record on load and then close the query when you close the app

select *
from your_table with (rowlock)
where id = x
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

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

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

810 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