Home > SQL Server > Get column name using COL_NAME function – SQL Server

Get column name using COL_NAME function – SQL Server


Col_Name() function returns the name of the column for given table id and column id.

This function takes two arguments Tableid and Columnid. To get the correct value from this function user should have the access to that table object. Otherwise, this function returns null value.

Function syntax

COL_NAME(Tableid int , Columnid int)

Example

pic1An alternative way to get the column names of a table is by using catalog view sys.columns.

Example

pic2

Advertisements
Categories: SQL Server Tags:
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: