In this article I will explain with an example, how to get Column names from a Database table in SQL Server.
This article will discuss two methods to get Column names from a Database table:
1. Using SQL Query
2. Using Stored Procedure
 
 
Database
Here I am making use of Microsoft’s Northwind Database. You can download it from here.
 
 
Fetch Column Names of Table using SQL Query
The INFORMATION_SCHEMA.COLUMNS table returns information about all columns within a Database. A SELECT statement needs to be executed over the table and the Table Name whose Column names needs to be fetched is displayed in WHERE clause.
Syntax
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Your Table Name'
ORDER BY ORDINAL_POSITION
 
Example
In the following example, the  Column names of Employees table of Northwind Database are fetched.
SELECT COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'Employees'
ORDER BY ORDINAL_POSITION
 
Screenshot
Tip Query to get all column names from database table in SQL Server
 
 
Fetch Column Names of Table using Stored Procedure
The System Stored Procedure sp_columns returns Column names with additional information from the Database table in SQL Server.
Syntax
EXEC sp_columns 'Your Table Name'
 
Example
In the following example, the Column names of Employees table of Northwind Database are fetched using the Stored Procedure sp_columns.
EXEC sp_columns 'Employees'
 
Screenshot
Tip Query to get all column names from database table in SQL Server