• We have to leave that function in place because other apps use it to generate single codes when needed. It is the approved method of generating codes and I didn't want to create a maintenance problem by having a second version of that process, so calling the original function in the new one kinda makes sense. I'm having a little trouble figuring out the last query though... this isn't working...
    select CustomerID, RewardItemCode, c.PromoCode
    from CodesToProcess --(my CTE)
    join (select PromoCode from WBCData_Sandbox.dbo.GetMultiplePromoCodes(CodesToProcess.NumOwed)) c on 1=1

    Not sure how to figure out the right syntax for that? Maybe I need more coffee 🙂