COL_NAME

Transact-SQL Reference

Transact-SQL Reference

COL_NAME

Returns the name of a database column given the corresponding table identification number and column identification number.

Syntax

COL_NAME ( table_id , column_id )

Arguments

table_id

Is the identification number of the table containing the database column. table_id is of type int.

column_id

Is the identification number of the column. column_id parameter is of type int.

Return Types

sysname

Remarks

The table_id and column_id parameters together produce a column name string.

For more information about obtaining table and column identification numbers, see OBJECT_ID.

Examples

This example returns the name of the first column in the Employees table of the Northwind database.

USE Northwind
SET NOCOUNT OFF
SELECT COL_NAME(OBJECT_ID('Employees'), 1)

Here is the result set:

EmployeeID

(1 row(s) affected)

See Also

Expressions

Metadata Functions

sysobjects