How to get all the column names of a table in SQL Server ?


This content was proof-read by Grammarly. You can Try Grammary for FREE

If you have a scenario where you need to get all the column names of a table in SQL Server , you can query the database’s INFORMATION_SCHEMA.Columns table by specifying the table name.

How to get all the column names of a table in SQL Server ?

Here’s a query to demonstrate how to achieve this.

Use AdventureWorks2014
GO

SELECT * From INFORMATION_SCHEMA.COLUMNS
where TABLE_NAME = N'Employee'

This would display all the columns of the table “Employee” and its information from the AdventureWorks2014 table.

image
Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

Newsletter Signup

Subscribe to our weekly newsletter below and never miss the latest product or an exclusive offer.

%d bloggers like this: