Header add

In this article we will learn How to get all column names from database table in SQL Server.

We will discuss here how to get Column names from a Database table in SQL Server.

Using two methods we can get Column names from a Database table:

1. Using SQL Query

2. Using Stored Procedure



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


Example

In the following example, the Column names of Customers table of my database are fetched.

Select columns 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. This are inside on Stored Procedures -> System stored procedures.

Syntax

EXEC sp_columns 'Table Name'

System stored procedure







  Summary
In this tutorial we discussed how to get all column names from database table in SQL Server. If have any question related to this topic then give your feedback.

Post a Comment

Previous Post Next Post