In this article we will learnt about Find all the Columns name in a table. 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. Please read my previous article difference-between-temporary-tables-table-variable-and-cte.
- 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:
So far in this article we discussed how to Find all the Columns name in a table.