Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 select * from view performance

Author  Topic 

azamsharp
Posting Yak Master

201 Posts

Posted - 2011-06-29 : 15:39:45
I have a view that returns bunch of columns and then I perform the following query:

select * from myView;

Is is bad to do select * on a view? I know when selecting from table it is a good idea to name the columns that we want instead of doing * on the select query but does the same applies when selecting from the view.

Mohammad Azam
www.azamsharp.net

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-06-29 : 15:51:56
There is no problem to begin with, since the view is designed to only return the columns YOU want.
But afer a while, someone will alter your view and add a new column because the other person doesn't like to create a almost duplicate view.
Never use * in production environment, except as an argument for count or EXISTS.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2011-06-30 : 11:11:33
The other advavatage of specifying columns is that if you are using an application , you can use arrays .
For example RecordsetRead(0),RecordsetRead(1) etc

Jack Vamvas
--------------------
http://www.sqlserver-dba.com
Go to Top of Page
   

- Advertisement -