Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 ABOUT THE LOCKS on SQL SERVER

Author  Topic 

pipi
Starting Member

18 Posts

Posted - 2005-08-05 : 02:18:06
Goodmorning!
Do you know if sqlserver lock the database even if i execute a select statement( a simple select *),not update or delete.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-05 : 02:23:10
Yes. Thats known as Shared Lock and it will lock only that table and not the database
If you want not to lock the table you can apply NoLock hint

Select * from yourtable(NoLock)

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Stalker
Yak Posting Veteran

80 Posts

Posted - 2005-08-05 : 07:44:08
>>and it will lock only that table and not the database

actually there is also shared lock on the database
Go to Top of Page

paulrandal
Yak with Vast SQL Skills

899 Posts

Posted - 2005-08-05 : 11:20:28
quote:
Originally posted by Stalker

>>and it will lock only that table and not the database

actually there is also shared lock on the database


Yup - all connections to a db take a shared lock to stop it being dropped or put into single-user mode (unless forced).

Paul Randal
Dev Lead, Microsoft SQL Server Storage Engine
(Legalese: This posting is provided "AS IS" with no warranties, and confers no rights.)
Go to Top of Page
   

- Advertisement -