Select column names and column data from SQL table

In SQL Management Studio Select the database environment that contains the table that you want to query.
The following command displays all the columns in all the table in thje current database:

select * from information_schema.columns

 You will notice that this result set returns usefull data on the table.

To select this information from a specific table in the  database,
use the following command:

select * from information_schema.columns

where TABLE_NAME = ‘YOURTABLE’

  where YOURTABLE is the name of the table you wish to select on.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s