HOW TO FIND COLUMN NAME USING COL_NAME() FUNCTION?

Sushant Mishra

Total Post:37

Points:185
Posted by  Sushant Mishra
 132  View(s)
Ratings:
Rate this:
  1. Sushant Mishra

    Post:37

    Points:185
    How to find Column Name Using COL_NAME() Function?

    SELECT COL_NAME(object_id('Sample..SignIn'),2) AS col_name 

     

    It takes two parameter table id and ordinal position and column name

    Also you can use

    SELECT
        name AS col_name FROM sys.columns
    WHERE
        object_id=object_id('Sample..SignIN') AND column_id=2


    output

      Modified On Sep-18-2017 07:11:26 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!