Wednesday 26 February 2014

SQL exists (but not exists)

We did some business data import and after the import there were some difference happening in what business provided the data and what system calculated using the config data.

To find the differences and placing the difference in front of client I used something similar

Select * from table1 t1
exists
( select * from table2 t2
where t2.column1 = t1.column3 and ( t2.column2 like '%' + cast( t1.column4 as varchar(10)) + '%' or t2.column2 like '%' + cast(t1.column5) as varchar(2)) + '%' )

 

No comments:

Post a Comment