Solved

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

Posted on 2013-06-25
1
278 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
Comment Utility
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

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

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Numeric sequence in SQL 14 36
SQl query 19 12
SQL Server creating a temp table 7 30
Azure SQL DB? 3 12
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

772 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

14 Experts available now in Live!

Get 1:1 Help Now