Logo 
Search:

SQL Server Articles

Submit Article
Home » Articles » SQL Server » Meta Data FunctionsRSS Feeds

COL_NAME Function

Posted By: Sarita Patel     Category: SQL Server     Views: 4738

This article explains about COL_NAME function in sql server with examples.

COL_NAME function is used to get name of database column by providing table identification number and column identification number. 


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.
  
Share: 

 
 

Didn't find what you were looking for? Find more on COL_NAME Function Or get search suggestion and latest updates.

Sarita Patel
Sarita Patel author of COL_NAME Function is from United States.
 
View All Articles

Related Articles and Code:


 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!