snippetsqlMinor
How to reset session in management studio tab?
Viewed 0 times
howtabsessionstudiomanagementreset
Problem
In a management studio tab, suppose I run code that creates a temp table.
Now if I re-run this code it gives an error that temp table already exists. I can open a new tab and run this code. This happens because each tab is a new session.
I know that using drop as initial part of the code is a solution. But, is there any way to get a new session (or reset the session) in the same window, so that I don't have to create new tab when re-running the code?
Now if I re-run this code it gives an error that temp table already exists. I can open a new tab and run this code. This happens because each tab is a new session.
I know that using drop as initial part of the code is a solution. But, is there any way to get a new session (or reset the session) in the same window, so that I don't have to create new tab when re-running the code?
Solution
Personally, I just put a DROP IF EXISTS at the front of the code. That makes it forever repeatable, and you don't get errors if you haven't created the table yet.
Otherwise, you can disconnect & reconnect the window without closing it. Pain the bottom, but then you don't have to change the code.
Otherwise, you can disconnect & reconnect the window without closing it. Pain the bottom, but then you don't have to change the code.
Context
StackExchange Database Administrators Q#295639, answer score: 5
Revisions (0)
No revisions yet.