col_name

Description

Returns the name of the column where the table and column IDs are specified, and can be up to 255 bytes in length.

Syntax

col_name(object_id, column_id [, database_id])

Parameters

object_id

is a numeric expression that is an object ID for a table, view, or other database object. These are stored in the id column of sysobjects.

column_id

is a numeric expression that is a column ID of a column. These are stored in the colid column of syscolumns.

database_id

is a numeric expression that is the ID for a database. These are stored in the db_id column of sysdatabases.

Examples

Example 1

select col_name(208003772, 2)
------------------------------ 
title

Usage

col_name, a system function, returns the column’s name.

Standards

ANSI SQL – Compliance level: Transact-SQL extension.

Permissions

Any user can execute col_name.

See also

Documentation Transact-SQL Users Guide

Functions db_id, object_id