You have a couple choices that I know of. There are advantages and disadvantages to both but here they are:
1) global temporary table
as
create table ##tmp_output (outval int NULL)
drop table ##tmp_output
2) create a dummy stored procedure
as
drop procedure sp_dummy
------------------------------------------
The any variable created in the EXEC command exist only in the context of that command, so the outer query would not be able to access it. That is why something must be created that spans the 2 queries (either a table or a stored procedure). If someone knows of a way to do this without the table or sp, I'd love to hear it.
Joshua J. Beck
Automobile Protection Corporation
http://www.easycare.com
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!