What is wrong with below Sql Queries?

SELECT ID FROM TEST1
UNION ALL
SELECT * FROM TEST2

 Posted by vishalneeraj-24503 on 1/2/2015 | Category: Sql Server Interview questions | Views: 537 | Points: 40
Answer:

It will give error as

Msg 205, Level 16, State 1, Line 1
All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.I means mis-match in the No of Columns in the select queries combined by the UNION Operator. In Union/Union All,No of columns must be the same.


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response