Click here to Skip to main content
15,922,325 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Friends,

What are the ways available to execute a lengthy select statement so that it should not lock the table. What should I add to select statement.

Thanks,
Jagjot
Posted

WITH NOLOCK

Something like:
SQL
SELECT * FROM MyTabel WITH (NOLOCK)


Have a read here:
Locking Hints[^]
Table Hints[^]

If needed, just Google for more.
 
Share this answer
 
Hi,

One of the problems is that in normal operation shared locks are needed for example to prevent dirty reads.

One possibility is to use row versioning which is defined at database level: Data versioning in SQL Server using row versions[^]. Actually this isn't exactly what you asked since locks are still used but for example exclusive locks won't block reading anymore etc.

Regards,

mika
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900