I am currently trying to set up a stored procedure to create a temporary
table, based on different conditions, and I am using the 'sp_executesql'
statement to execute this statement. What I need to do is then use this
table that I just created in the creation of a second statement. This second statement is a select statement that includes the use of the temporary table that was just created. This statement will also be executed using the sp_executesql stored procedure. Once the first sp_executesql statement is executed, the temporary table is not recognized. I believe this is because the sp_executesql is its own session. Is there any way to accomplish what I am looking to do?