SQL Where statment help
Posted on 2014-08-28
The last part of the WHERE needs to be different every month; the numbers behind "N##" correspond to a month. They need to roll forward each month - the below script is setup for August, but for September, the N09 needs to change to N03; in October, the N10 would change to N04, and so on. ' NS' doesn't change and is constant.
I've tried CASE, but can't get it to hit multiple fields. One thought was to use a series of SQL jobs to update a temp table with the proper number series each month. Another was to build some if/then into SSRS.
set exclude_from_ranking = 'N', exclude_from_reclassification = 'N', date_last_modified = getdate(), last_maintained_by = 'ABIX_DBA'
where exclude_from_ranking = 'Y' and exclude_from_reclassification = 'Y'
and purchase_class_id in ('N11', 'N12', 'N01', 'N02', 'N09', 'N10', 'NS')