object_name

Description

Returns the name of the object with the object ID you specify; can be up to 255 bytes in length.

Syntax

object_name(object_id[, database_id])

Parameters

object_id

is the object ID of a database object, such as a table, view, procedure, trigger, default, or rule. Object IDs are stored in the id column of sysobjects.

database_id

is the ID for a database if the object is not in the current database. Database IDs are stored in the db_id column of sysdatabases.

Examples

Example 1

select object_name(208003772)
------------------------------ 
titles

Example 2

select object_name(1, 1)
------------------------------ 
sysobjects 

Usage

object_name, a system function, returns the object’s name.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute object_name.

See also

For general information about system functions, see “System functions”.

Functions col_name, db_id, object_id

System procedure sp_help