One way to accomplish this is to create dynamic sql that is sets a local variable via sp_executesql using the out parm, then use that variable in the next dynamic sql statement. Check out this example of how to set the local variable via sp_execute_sql:
http://www.geocities.com/sqlserverexamples/#dyn1
-------------------------
Gregory Larsen, DBA
If you looking for SQL Server Examples check out my website at http://www.geocities.com/sqlserverexamples