Using Visual Studio 2005/2008 to easily insert column names into a stored procedure

by Dominic Zukiewicz 8. October 2008 15:13

When writing stored procedures or views, I always create them in Visual Studio (2005/2008) and then run them on a specified database. When using "SELECT *", it is compact, but obviously does not help you find the columns of the table or view.

When using the IDE, I added a new SQL Script for Stored Procedures, and then I typed:

SELECT *
FROM Customers

and a blue box surrounded the statement. I right-clicked -> Design SQL Block.

The designer then listed all of the column names for me, and when clicking OK, instantly put them back into the SQL script I was creating!

SELECT  CustomerID, CompanyName, ContactName, ContactTitle, 
Address, City, Region, PostalCode, Country, Phone, Fax
FROM Customers

For the table I was using, this list over 60 columns for me!

So if you want a quick way of listing all of the column names for table of view:

  1. Add a database project to your site (if you haven't already done so)
  2. Right click Queries -> Add SQL Script
  3. Choose Stored Procedure Script
  4. Type your SELECT * From XYZ statement
  5. Right click -> Design SQL Block
  6. Click OK.

The designer will be updated with the new query.

Tags:

Visual Studio IDE (2005/2008)

Powered by BlogEngine.NET 1.5.0.7
Theme by Interakting

Interakting

A full service digital agency offering online strategy, design and usability, systems integration and online marketing services that deliver real business benefits and ensure your online objectives are met.

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar