Let’s suppose you are executing the given queries in SQL Server.
Select 1,2
UNION All
Select 1,2,3
Error Message:
But getting the below error.
Msg 205,Level 16, State 1, Line 2 All queries combined using a UNION, INTERSECT or EXCEPT operator must have an equal number of expressions in their target lists.
Causes:
In above SQL statement, Columns are not equal in both queries because Union ALL operator is used to combine multiple query result set but all queries columns must be equal.
Solution of the Error:
To avoid this error, you need to remove extra column from query which exists in any query.
In above query, we have extra field [3] in query 2. So now removed it and correct query is mentioned below.
Solution of above
Select 1,2
UNION All
Select 1,2
Output :
1 2
1 2
If you want to sell your readymade software to the genuine clients or businessman, list your software with details and demo links.
Clients will find it using our advanced search filter and will contact you directly.
No any charge for the product lsiting.