DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
SITE SEARCH SQLUSA.com HEADLINES NEWS
SQL E/BOOKS   SQL 2014 PROGRAMMING   DOWNLOADS
SCRIPTS SQL 2005 SQL 2008 ARTICLES
SQL JOBS TWITTER FORMAT VIDEOS
How to avoid using SELECT * FROM?

DBA-s and database developers frequently use SELECT * as part of their daily work. It is a great shorthand.

However, it is undesirable to include select * from in your PRODUCTION code or stored procedure because if a column is added or deleted, you can expect a sure bug.

With sp_help TableX you can easily get a column list. Just cut and paste it, add commas and you have the select with the explicit column list.

You can also do this from SSMS Object Explorer by scripting out the table.

Similar consideration for the INSERT statement: specific column list should be included.

 

Related article:

Caution: Avoid Using SELECT * in a SQL View

 

Exam Prep 70-461
Exam 70-461
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE