SQL SERVER – Puzzle – SELECT * vs SELECT COUNT(*)
- by pinaldave
Earlier this weekend I have presented at Bangalore User Group on the subject of SQL Server Tips and Tricks. During the presentation I have asked a question to attendees. It was very interesting to see that I have received various different answer to my question. Here is the same question for you and I would like to see what your answer to this question.
Question: SELECT * gives error when executed alone but SELECT COUNT(*) does not. Why?
Select * - resulting Error
Select count * - NOT resulting Error
Please leave your answer as comment over here. If you prefer you can blog post about this on your blog and put a link here. I will publish valid answer with due credit in future blog posts.
Reference: Pinal Dave (http://blog.SQLAuthority.com)
Filed under: PostADay, Readers Question, SQL, SQL Authority, SQL Puzzle, SQL Query, SQL Server, SQL Tips and Tricks, T SQL, Technology