Syntax of COL_NAME Function :
COL_NAME ( table_id , column_id )
table_id is identification number of table. It is of type int.
column_id is identification number of column. It is of type int.
Return type of COL_NAME function is sysname.
Examples of COL_NAME Function :
Example 1 : Use of COL_NAME function in select clause
SELECT COL_NAME(OBJECT_ID('Customers'),2)
Output
CompanyName
Above example returns name of the second column of Customers table. Here OBJECT_ID() function is used to get identification number of customers table.