March 31, 2016 at 3:31 am
Almost silly question that I'm curious about.
Can I drop a local temp table owned by myself in another session?
I can't just use drop because I get the 'does not exist or you do not have permission' error.
When I'm coding I generally have multiple windows open & cannot drop local temp tables I created in other windows. I know they're mine. It's unimportant in a way as I can just bob back to my original session & drop the table.
This works with global temp tables.
Presumably it's something to do with the numbered suffix on local temp tables? Either way I can't suss it.
March 31, 2016 at 3:46 am
snomadj (3/31/2016)
Can I drop a local temp table owned by myself in another session?
No. Temp tables are session-scoped, you cannot access a temp table created in another session, not to read it, not to drop it.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
March 31, 2016 at 5:25 pm
GilaMonster (3/31/2016)
snomadj (3/31/2016)
Can I drop a local temp table owned by myself in another session?No. Temp tables are session-scoped, you cannot access a temp table created in another session, not to read it, not to drop it.
Actually, you can:
KILL @SPID
😉
_____________
Code for TallyGenerator
April 1, 2016 at 6:25 am
Sergiy (3/31/2016)
GilaMonster (3/31/2016)
snomadj (3/31/2016)
Can I drop a local temp table owned by myself in another session?No. Temp tables are session-scoped, you cannot access a temp table created in another session, not to read it, not to drop it.
Actually, you can:
KILL @SPID
😉
And you can restart your computer by formatting it.
April 1, 2016 at 7:30 am
Thanks all. I get the gist. Didn't know if there was a:
DROP TABLE [sessionID, databaseName, #tableName] command I didn't know about.
Appreciate your time to respond. Have nice weekends!
April 1, 2016 at 7:34 am
snomadj (4/1/2016)
Thanks all. I get the gist. Didn't know if there was a:DROP TABLE [sessionID, databaseName, #tableName] command I didn't know about.
Appreciate your time to respond. Have nice weekends!
If you have a process where you need sessions to talk to the same Temp Table, you could use a Global Temp Table to do such things.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 3, 2016 at 5:18 pm
Luis Cazares (4/1/2016)
Sergiy (3/31/2016)
GilaMonster (3/31/2016)
snomadj (3/31/2016)
Can I drop a local temp table owned by myself in another session?No. Temp tables are session-scoped, you cannot access a temp table created in another session, not to read it, not to drop it.
Actually, you can:
KILL @SPID
😉
And you can restart your computer by formatting it.
Not really.
Formatting a hard drive does not actually restart the computer.
🙂
_____________
Code for TallyGenerator
April 4, 2016 at 6:51 am
Sergiy (4/3/2016)
Luis Cazares (4/1/2016)
Sergiy (3/31/2016)
GilaMonster (3/31/2016)
snomadj (3/31/2016)
Can I drop a local temp table owned by myself in another session?No. Temp tables are session-scoped, you cannot access a temp table created in another session, not to read it, not to drop it.
Actually, you can:
KILL @SPID
😉
And you can restart your computer by formatting it.
Not really.
Formatting a hard drive does not actually restart the computer.
🙂
When it's the system hard drive it needs to restart to change the OS.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply