Forum Discussion
HassanShaddad
Nov 20, 2020Copper Contributor
Is there any way to make a count select statement without SharedLock on the table
I have a table and I have to count its rows every 10 m like (SELECT COUNT(ID) FROM dbo.MyTable) the problem that when I count the rows my select put a shared lock on the table and block any insert...
olafhelper
Nov 24, 2020Bronze Contributor
Yes, the SELECT create a shared lock on the table, but that don't block INSERTS, only DDL statements.
You can get the row count also from DMV's, that's much faster:
=>