Wednesday, 12 September 2012

Sql Server Scripts : Get column names of tables using inbuilt SQL Server Stored Procedure

There is a situations where you want to know the column names and it's data type and other column relevant  information of a particular table.
In SQL server there is inbuilt stored procedure "sp_columns" which returns columns information of specified table name.
Many people uses this traditional way to see column information. Like , In Microsoft SQL Server Management Studio Go to particular tables then open tables in design view mode. This way is very lengthy.
Using this inbuilt SP you can get quick result.

SQL Syntax :
sp_columns @table_name

@table_name : Specify table name.

SQL Query :
sp_columns product_master

Output :

(To view original image , click on image) 

Note : This output screen image has few columns information display. To View all return result information download .CSV file from here. 

This is the very useful SQL Server Scripts.

Note : Give Us your valuable feedback in comments. Give your suggestions in this article so we can update our articles accordingly that.

No comments:

Post a Comment