SQL Flow Field Guide

OBJECT_NAME

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
sysname

Syntax at a glance

OBJECT_NAME ( object_id [, database_id ] )

Work example

Resolve a visible object identifier to its name in a diagnostic query.

Pass the database id when the identifier belongs to another database and verify permissions.

Check your work OBJECT_NAME can return null when metadata is not visible or the object id is invalid.

Practice SQL

Open in SQL Flow
SELECT OBJECT_NAME(OBJECT_ID(N'sys.objects')) AS object_name;

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