• Okay yeah there's nothing stopping you from doing that, if you took that idea and used it to build however many select statements you were going to run that for then joined all the statements with a union.

    Something like SET @sql = @sql_one + ' UNION ALL ' + @sql_two + ' UNION ALL ' + @sql_three etc.....