• I may have to apologize at this point. For the last 20-30 minutes, I've been browsing through your extremely procedural code. I can only say that I would try to redesign it entirely to do validation based on columns, not variables, flag the appropriate action in yet another column, then execute the appropriate action. Unfortunately, I can't spare the time to fully understand and rewrite it.

    To keep you in the procedural code that you are apparently most comfortable with, my answer at this point has to be that I know of no way to dynamically create variables. What you CAN do is dynamically write the code to create user-defined functions and stored procedures, then execute them.

    This is going to run VERY slowly in production and creates all sorts of issues if you plan to do this as an application that multiple users can run. I don't advocate this, but it's the only suggestion I can think of to get you around the roadblock in the path you are on.

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills