Suppose there is a scenario when we require to fetch all the columns name with separated by commas then there is many ways to achieve this.
  • We can use ALT+F1 in the table name and fetch all the column information like name, data type, Length, Collation, Identity, RowGuid Col etc.
In this blog I will explain how to fetch all the columns using SQL Server Script. Use the below code you can fetch all the columns name just entering the Table name.

SELECT SUBSTRING(

    (SELECT ', ' + QUOTENAME(COLUMN_NAME)

        FROM INFORMATION_SCHEMA.COLUMNS

        WHERE TABLE_NAME = 'ContanctInfo'

        ORDER BY ORDINAL_POSITION

        FOR XML path('')),
    3,
  200000);

You can see in the below image: