sql server - Query to compare differences of two columns from two different tables -
i attempting create union query, on 2 differently named columns in 2 different tables.
i take "mtrl" column in table user_excel , compare against "short_material_number" column im_excel table. query homecoming differences between 2 columns. both columns house material numbers named differently (column wise) in tables.
what have far is:
(select [mtrl] dbo.user_excel except select [short_material_number] dbo.im_excel) union (select [short_material_number] dbo.im_excel except select [mtrl] dbo.user_excel)
however, when trying run query receive error message states:
msg 8114, level 16, state 5, line 22 error converting info type varchar float.
you're getting error because 1 of 2 columns float
info type, while other varchar
. this article place start reading implicit conversions, happen when seek compare 2 columns of different info types.
to working, need convert float varchar, in illustration below.
( select [mtrl] dbo.user_excel except select cast([short_material_number] varchar(18)) dbo.im_excel ) union ( select cast([short_material_number] varchar(18)) dbo.im_excel except select [mtrl] dbo.user_excel )
sql-server sql-server-2012 union
No comments:
Post a Comment