I am trying to see if field1 is in field2, field3, field4, or field5 by using
a simple field1 IN(field2, field3, field4, field5) statement. However, this
seems to work sporadically, and I am not sure how to accomplish this without
using a loop. Does anyone have a suggestion to keep this data comparison
simple? (I have already tried trimming the field values as well to no avail).
Thank you in advance!
That will work in principal, the IN is simply saying...
field1 = field2 OR field1 = field3 OR field1 = field4 OR field1 = field5
The complexity may be coming from data types - varchar / char etc...; do you
have the SQL you are using?
Tony Rogerson, SQL Server MVP
[Ramblings from the field from a SQL consultant]
[UK SQL User Community]
@discussions.microsoft.com> wrote in message
Hi! Yes, sure do - here ya go:
SET chk_tf_cast_first_name1 = 1
FROM tvg_compare_progrec A
INNER JOIN fyi_conversion.dbo.program_mapping B ON
A.tf_database_key_3 = cast(B.tvg_id AS varchar (12))
INNER JOIN fyi_compare_progrec C ON
cast(B.fyi_id AS varchar (12)) = C.tf_database_key_3
(A.tf_cast_first_name1 IS NOT NULL)
AND (A.tf_cast_first_name1 NOT IN (C.tf_cast_first_name,
C.tf_cast_first_name2, C.tf_cast_first_name3, C.tf_cast_first_name4))
It is so strange how it works for most but randomly will not for one of the
Thanks for your assistance!
Thanks Tony - I figured out my problem.