Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the equivalent of 'describe table' in SQL Server?

You can use the sp_columns stored procedure:

exec sp_columns MyTable

There are a few methods to get metadata about a table:

EXEC sp_help tablename

Will return several result sets, describing the table, it's columns and constraints.

The INFORMATION_SCHEMA views will give you the information you want, though unfortunately you have to query the views and join them manually.


Just in case you don't want to use stored proc, here's a simple query version

select * 
  from information_schema.columns 
 where table_name = 'aspnet_Membership'
 order by ordinal_position

You can use following: sp_help tablename

Example: sp_help Customer

OR Use Shortcut Keys

  • Select the desired table and press ALT+F1.

Example: Customer Press ALT+F1.


Use this Query

Select * From INFORMATION_SCHEMA.COLUMNS Where TABLE_NAME = 'TABLENAME'

In addition to the ways shown in other answers, you can use

SELECT TOP 0 * FROM table_name

This will give you the name of each column with no results in them, and completes almost instantly with minimal overhead.