Powered by Blogger.

Saturday, February 15, 2014

How to get Column names of table in SQL Server 2008?



In this post we will discuss how to get all the column names of a database table in SQL Server 2008.

You can also check my previous posts on:

- Update record using Enterprise library in Asp.Net

- Implement SQL Server authentication in asp.net

- Difference between primary key and foreign key in SQL server

Below is the query that will retrieve the column names of a table.

select COLUMN_NAME from information_schema.columns
 where table_name = 'CountryMaster'
order by ordinal_position

Check the figure below:

Also if you will run the below query, then you will get some additional details:

select COLUMN_NAME,* from information_schema.columns
 where table_name = 'CountryMaster'
order by ordinal_position



0 comments

Post a Comment