I have a stored procedure which does the following:
Create a temporary table (
#tmp1
) from aSELECT.. INTO.. FROM..
syntax.Build a querystring and execute it using
EXEC(@STR1)
. The querystring also do a query to#tmp1
.
The reason why the querystring is built on a string variable is because there are some condition in forming the query.
The problem now is because the 2nd query can't access #tmp1
since it's on different connection. I can create a global temporary table and drop it upon completion but am concerned on the implication when multiple users are triggering the stored procedure at the same time.
Appreciate ideas or workaround for this issue. Thank you in advance.