Difference between sql select statement

Posted by Karthik2010_Mca under Interview Questions on 3/3/2013 | Points: 10 | Views : 1269 | Status : [Member] | Replies : 7
Hi,

Testtable is a table name having 3 columns like column name as a, b, c
Difference between below sql query

select * from Testtable
select a, b, c from Testtable

Thanks in advance
Karthik.K

Karthik


Responses

Posted by: Santhi on: 3/3/2013 [Member] Starter | Points: 25

Up
0
Down
Hi

Refer this link:
This may help you
http://social.msdn.microsoft.com/Forums/en/transactsql/thread/211316c5-37f2-4764-8c48-3116f9e63ea9

Thanks & Regards,
Santhi .V

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj.Trivedi on: 3/3/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hello Karthik2010_Mca

The main issue will be of performance and if you are using Joins then it can take long time to fetch results.


Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mutturaj on: 3/3/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Raj Trivedi,

Which one is better option based on the Performance issue..?
select * or select [all columns]..??

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Somu475 on: 3/3/2013 [Member] Starter | Points: 25

Up
0
Down
Hi Mutturaj...

Refer the following site...

http://gertjans.home.xs4all.nl/sql/dont-use-select-star-in-production-code.html

-Somu

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ankitsrist on: 3/3/2013 [Member] Starter | Points: 25

Up
0
Down
hello, it all depends on performance, select * from Testtable will slow down your execution time this will fetch all column data, and query like select a, b, c from Testtable will fetch particular column data so increase performance it is useful if you know which data should fetch...so according to your need you can use any query type

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Raj.Trivedi on: 3/3/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hello Mutturaj

I will go for select [all columns] that will allow me to manipulate the columns and restrict no extra data coming into data set from SQL and hence increasing performance.

So to summarize it is better to use select [all columns] as per need.

Regard's
Raj.Trivedi
"Sharing is Caring"
Please mark as answer if your Query is resolved

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mutturaj on: 3/3/2013 [Member] Starter | Points: 25

Up
0
Down
Thanks a lot to all...
Link given by Somu475 has good explaination about this.

Karthik2010_Mca, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response