• You cannot specific the sql statement as a variable for the cursor.

    The easiest was around this is to include the whole cursor operation into your dynamic sql statement.