I have a need to compare the number of rows returned from table A when it is joined to table B to the number of rows returned when there are no joins involved. If the number of rows returned are the same, then I need to proceed to execute my next step else end.
So, If RowCount A = RowCount A when A joined to B
THEN Goto Next Step
I need to put the above logic in a sp that I want to execute using a job.
DECLARE @countTotal INTEGER
SELECT @countTotal = COUNT(*) FROM TableA
DECLARE @countJoin INTEGER
SELECT @countJoin = COUNT(DISTINCT TableA.ID) FROM TableA INNER JOIN TableB ON (TableA.Col = TableB.Col)
IF @countTotal = @countJoin BEGIN
-- Do something
-- Do something else