Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exec vs. Temp Table 2

Status
Not open for further replies.

Pranklin

Programmer
Jun 4, 2002
1
AU
Can anybody explain why this does not work:

EXEC ('CREATE TABLE #tmpMine (MyData Int)')
EXEC ('INSERT INTO #tmpMine (MyData) VALUES (54)')
EXEC ('SELECT * FROM #tmpMine')

I get the following errors:

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name '#tmpMine'.
Server: Msg 208, Level 16, State 1, Line 1
Invalid object name '#tmpMine'.


And yes for specific reasons I have to use Exec.

This is using SQL 8.00.

Thanks in advance for your help.
 
Because temp tables goes out of scope (and are dropped) at every execution of "EXEC". You'd have to include all the commands into a single stored procedure.
 
Could you explain why you have to use EXEC, I'd be very interested ?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top