Using * in SQL VIEW definitions

Do not use * in column list of SQL VIEW definitions!

CREATE VIEW bad_view
AS
SELECT * FROM some_table

SQL Server will introduce some problems when the underlying table structure changes.
If for example You insert some columns between pre-existing ones into some_table above
the view result will be shifted and result columns appear below bad column headers!
This may occure without any sign of error!

Read more:
http://blog.sqlauthority.com/2010/09/15/sql-server-select-and-adding-column-issue-in-view-limitation-of-the-view%C2%A04/

Leave a Reply