• Trader - just print the @SQL first - your error will likely pop right up at ya... If you don't see it - paste it into a new query window and see what the parser has to say about it.

    Meaning

    ...

    Print (@SQL)

    Exec (@SQL)

    Also - You can't "build and execute" at the same time. EXEC wants a static string (meaning - something fully built before you pass it to execute), not some concatenation operation happening inside the EXEC statement.

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?