Is it possible to write these two blocks of code as one? The only
difference between them is the AND clause: AND is_trade_date = 1 versus AND
is_sett_date = 1.
Cheers,
David
IF (@trade_dates = 1)
BEGIN
IF EXISTS (SELECT 1 FROM calendar
WHERE calendar_date = @date
AND is_trade_date = 1)
BEGIN
SELECT @day_cnt = @day_cnt + 1
END
END
ELSE
BEGIN
IF EXISTS (SELECT 1 FROM calendar
WHERE calendar_date = @date
AND is_sett_date = 1)
BEGIN
SELECT @day_cnt = @day_cnt + 1
END
END
END