Yesterday was the first anniversary of this unanswered question. It still applies, to Version 16 as well as 12... if one was impolite, one might ask "What is the point of CONNECTION_PROPERTY ( 'LockCount' ) if it returns zero for a connection that is holding a schema lock that is actually blocking another connection?" :)
Here is a query run in 126.96.36.19998 that shows one schema lock exists but DB_PROPERTY ( 'LockCount' ) returns zero. The same is true for CONNECTION_PROPERTY ( 'LockCount' ).
select DB_PROPERTY ( 'LockCount' ), * from sa_locks(); DB_PROPERTY('LockCount'),conn_name,conn_id,user_id,table_type,creator,table_name,index_id,lock_class,lock_duration,lock_type,row_identifier '0','OLTP1_update',12,'DBA','BASE','DBA','t',,'Schema','Transaction','Shared',
If there are a million locks, will the following workaround be optimized or will it be slowwwwww?
SELECT COUNT(*) FROM sa_locks(); COUNT() 1