Returns the name of a database column given the corresponding table identification number and column identification number.
COL_NAME(table_id, column_id)
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 each column in the authors table of the pubs database.
Note The table identification number was generated by executing OBJECT_ID.
USE pubs
SET NOCOUNT OFF
SELECT COL_NAME(117575457, ORDINAL_POSITION)
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'authors'
Here is the result set:
column_name
------------------------------------------------------------------------
au_id au_id
au_lname au_lname
au_fname au_fname
phone phone
address address
city city
state state
zip zip
contract contract
(9 row(s) affected)
Expressions | Metadata Functions |
sysobjects |