|
Posted by Erland Sommarskog on 02/20/07 23:20
Roy Harvey (roy_harvey@snet.net) writes:
> Don't forget that if the SELECT * is in a stored procedure or a view,
> the * is resolved into the columns when the procedure is CREATEd or
> ALTERed. If you do not remember to re-ALTER them after a change to
> the underlying table they will not reflect the current table
> structure.
True for a view, but since SQL 7 no longer for a stored procedure.
In my opinion, SELECT * from a temp table created in the same stored
procedure is OK, because you have full control. But else, it's a no-no
in my book. The database designer adds or drops a column, the result
set changes, and the client breaks. (Yes, if columns are explicitly listed,
and you drop a column, the procedure breaks. But that can be discovered
by building the database from scripts.)
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
Navigation:
[Reply to this message]
|