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
 General SQL Server Forums
 New to SQL Server Programming
 silly question

Author  Topic 

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-16 : 03:05:50
Hi all. I think its a silly question to ask. What is better to use? I mean in terms of performance.
c.* or c.field1, c.field2, c.field3, c.lastfield..... ?

thanks
-Ron-

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2007-03-16 : 06:54:07
not silly....answer just not necessarily obvious.

c.field1, c.field2, c.field3, etc...is better
c.*....will require a data lookup...where as 1st form may be satisfied by a covering index.

Also...better practice to 'know' what fields are returned by SQL code, rather than leave it up to chance by dint of actions of some future DBA....ie adding in 1 extra column or worse deleting 1 column (without checking all instances of where it's used!)

Also if the extra column includes TEXT/image...then performance will go way west!!!


"Short-cut Scripts" are available turn C.* into c.field1, c.field2, etc...search here for references to same....may be posted on some of the related blogs.
Go to Top of Page

cwtriguns2002
Constraint Violating Yak Guru

272 Posts

Posted - 2007-03-16 : 08:02:08
thanks Andrew Murphy for the reply and explanation. Now i get it.

-Ron-
Go to Top of Page
   

- Advertisement -