What is a NOLOCK?

Answers were Sorted based on User's Feedback



What is a NOLOCK?..

Answer / michael

Advantage:
applying nolock in select statement will increase
concurreny and performance in fetching.

Disadvantage:
it does'nt consider the transaction scenario, even if the
transaction is under process not yet commited or rollback
it will fetch the current record
eg

begin tran
insert into tablename
values('1','asdf')

select * from tablename with (nolock)

-- it will display the table with inserted record.
but the transaction is not completed, it can be rollback
so it became dirty read.

Is This Answer Correct ?    28 Yes 2 No

What is a NOLOCK?..

Answer / naren

Using NOLOCK politely asks SQL Server to ignore locks and
read directly from the tables. This means you completely
circumvent the lock system, which is a major performance
and scalability improvement. However, you also completely
circumvent the lock system, which means your code is living
dangerously. You might read the not-necessarily-valid
uncommitted modifications of a running transaction. This is
a calculated risk.

Is This Answer Correct ?    19 Yes 1 No

What is a NOLOCK?..

Answer / guest

Do not issue shared locks and do not honor exclusive locks.
When this option is in effect, it is possible to read an
uncommitted transaction or a set of pages that are rolled
back in the middle of a read. Dirty reads are possible. Only
applies to the SELECT statement.

Is This Answer Correct ?    16 Yes 3 No

Post New Answer

More SQL Server Interview Questions

how to get max salary with employee number by using one select query and max function ??

3 Answers   Genpact,


Department ----------- salary Deptname 1000 A 3000 A 2000 B 3000 B 4000 C 5000 C select the deptname where salary >=5000 result should be: Deptname --------- C please post only executed query in SQL server 2005 Asked By: Md. Niyaz

3 Answers  


Is sql server 2016 free?

0 Answers  


How to specify the collation for a character data type in ms sql server?

0 Answers  


How to write a query with an inner join in ms sql server?

0 Answers  






What is cursors? And what are the different types of cursor?

0 Answers  


select the 3rd maximum salary from sql server database if 4 (just an example In practically I may not know the exact situation) of the highest salaries are equal.

8 Answers   TCS,


What is best institute to Learn DotNET And SQL in chennai?

0 Answers  


Do you know spatial data types - geometry and geography in sql server 2008?

0 Answers  


What is the definition for sql server 2000?

0 Answers  


What is stretch database in sql server?

0 Answers  


What are the different subsets of sql?

0 Answers  


Categories