Solved

If I don't use Nolock on a select statement...

Posted on 2013-06-25
1
282 Views
Last Modified: 2013-06-25
Can I lock up data?
0
Comment
Question by:patriotpacer
1 Comment
 
LVL 20

Accepted Solution

by:
dsacker earned 500 total points
ID: 39276151
Potentially, yes. Within a pristine design, usually no.

For instance, if you have a query without the NOLOCK that does lengthy table scans, against fields that are not indexed, etc., you could lock the table. If others are trying to update that table, they could be in a wait state until your query finishes.

If you have good indexing, and tailor your queries accordingly, even though some deadlocking may still occur, the query is usually very quick and will use indexing efficiently. Very little deadlocking will occur.

In general, WITH (NOLOCK) will prevent locking the table, if you don't mind having the potential of "dirty" reads. I know programming shops where it is still an offense subject to termination if queries do not include the WITH (NOLOCK).
0

Featured Post

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!

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.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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.

808 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