Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Union all error must have equal number of expressions

I am trying to run this query but I am getting this error:

All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.

What am I doing wrong here? Please help.

SELECT      *
into       #xx 
From (
Select *
FROM #x 
union all  
select * from MartDB.DBO.BAW_AllSources_Stage1
) AAAsds
like image 638
user2447136 Avatar asked Jan 27 '23 22:01

user2447136


1 Answers

Your inner query part

Select *
FROM        #x 
union all  
select * 
from MartDB.DBO.BAW_AllSources_Stage1

has * in both queries participating in UNION.

Check and see if the both *s translate into same number of columns and data type in order.

like image 185
DhruvJoshi Avatar answered Feb 03 '23 06:02

DhruvJoshi