How to get Column names of a Table or a View in SQL Server

Here is a simple query you can use to get column names of a specified table or a view in SQL Server (replace Schema_Name and Table_Name with correct values in the query):

SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'Schema_Name'
AND TABLE_NAME = 'Table_Name'

The INFORMATION_SCHEMA.COLUMNS view provides information about columns of all tables and views in a database. So the query above can be used to get a list of columns of a table and a view.

You can get following information for each table or view column:
TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME, ORDINAL_POSITION, COLUMN_DEFAULT, IS_NULLABLE, DATA_TYPE, CHARACTER_MAXIMUM_LENGTH, CHARACTER_OCTET_LENGTH, NUMERIC_PRECISION, NUMERIC_PRECISION_RADIX, NUMERIC_SCALE, DATETIME_PRECISION, CHARACTER_SET_CATALOG, CHARACTER_SET_SCHEMA, CHARACTER_SET_NAME, COLLATION_CATALOG, COLLATION_SCHEMA, COLLATION_NAME, DOMAIN_CATALOG, DOMAIN_SCHEMA, DOMAIN_NAME

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA = 'Schema_Name'
AND TABLE_NAME = 'Table_Name'