SQL Flow Field Guide

APPLOCK_TEST

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

catalog lookup

What changes

Input
catalog metadata (object, column, index, file, database properties)
Output or change
id, name or property value
Return type
smallint

Syntax at a glance

APPLOCK_TEST ( 'database_principal' , 'resource_name' , 'lock_mode' , 'lock_owner' )

Work example

Check whether an application lock request would be granted for a selected mode.

Use schema-qualified names and test missing and permission-hidden objects separately.

Check your work The result is a point-in-time check and can change before a later lock request.

Open Microsoft Learn for full syntax, permissions, and details for your version.