I need to figure out what kind of locking is being used on different tables in my SQL Server database. I want to write a query that can show me the lock settings for each table by looking at the system metadata.
I already checked the sys.objects view but I couldn’t find any obvious columns that would tell me about the locking behavior. Are there other system views or DMVs that I should be looking at instead?
Basically I want to run a query that returns something like:
SELECT
t.table_name,
t.lock_type,
t.lock_escalation
FROM some_system_view t
WHERE t.object_type = 'USER_TABLE'
What would be the correct way to get this information from the system catalog?
Interesting question! Try checking sys.tables instead of sys.objects - that view has a lock_escalation column which might be what you’re looking for. Are you troubleshooting performance issues or just doing general database analysis? What got you looking into locking mechanisms?
yeah, sys.tables is def the way to go. you can combine it with sys.partitions if you need row-level vs page-level locking hints, but sys.tables.lock_escalation_desc covers basic lock escal settings. don’t overthink it!
Just query sys.tables directly - it’s got the lock_escalation column that shows each table’s escalation setting:
SELECT
SCHEMA_NAME(schema_id) AS schema_name,
name AS table_name,
lock_escalation_desc AS lock_escalation_type
FROM sys.tables
WHERE type = 'U'
You’ll get back TABLE, DISABLE, or AUTO for each table’s lock escalation behavior. If you want to see what’s actually happening with locks right now, check sys.dm_tran_locks - but that’s more for monitoring active locks, not the table settings you’re looking for. Stick with sys.tables for the static config stuff.