All Type Coding

Search Here

How can get all cloumn name of a table in sql server

Here I am explaining How to get all columns of a table in sql server.Let's say we have a table Employee2








Now I want to get all columns of Employee2 table.Let's see how to get all columns of the Employee2 table using command.
For getting all columns of a table execute below command.
Syntax:
Select  COLUMN_NAME 'All_Columns' from
INFORMATION_SCHEMA.COLUMNS  where TABLE_NAME='Your table name'

For Example:
Select  COLUMN_NAME 'All_Columns' from
INFORMATION_SCHEMA.COLUMNS 
where TABLE_NAME='Employee2'


After executing the above query the output will be shown like below























If you want to get entire thing of a table then execute below command 
SELECT *
FROM Test.INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = N'Employee2'

No comments :

Post a Comment