Returns the name of a database column given the corresponding table identification number and column identification number.
COL_NAME ( table_id , column_id )
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.
sysname
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.
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)