See
How to return a value from dynamically executed T-SQL code FAQ #8130
>I have the following store procedure that computes the sales between specific months in a year.
>I build the query dynamically and submit it via EXEC. I need the result from the EXEC in the routine to output it. I'm now doing this via a temp table but I'd like to know if there is a better way to do this( e.g. using variables)
>
>
<snip>
--sb--