Quantcast
Channel: Forum SQL Server Database Engine
Viewing all articles
Browse latest Browse all 15694

SQL Server 2012 Management Studio (SSMS 2012): Database Engine Query - Retrieve data from 2 tables. MSG 205. All query combined using a UNION operator must have an equal number of expressions in their target lists?

$
0
0

Hi all,

I am rusty in doing T-SQL and I am new in doing Database Engine Query.

I have 2 dbo Table in SSMS 2012 and in the Database Engine Query, I executed the following T-SQL code in my SSMS 2012:

    SELECT Pt_ID, X, Y, Sample_id, Boring
    FROM  dbo.Table_1_APG_XYcoord
    WHERE sample_id<6
UNION
    SELECT Boring, sample_id, Unit, Arsenic,  Chromium, Lead
	FROM dbo.Table_2_APG_Soil
	WHERE sample_id>0
ORDER BY sample_id

I got the following:

MSG 205, Level 16, State 1, Line 1

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

I have no ideas what the MSG means and how to correct the problem.  Please kindly help, advise and respond.

Thanks in advance,

Scott Chang


Viewing all articles
Browse latest Browse all 15694

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>