January 30, 2012 at 3:06 pm
What is driving the question is that I often write or troubleshoot stored procs that are complex or very long and in order to completely refresh the query window, I currently disconnect then reconnect the query window using the context menus and the graphical connection tools.
It would help my productivity if I could temporarily plop some TSQL at the top of the proc that would redo the connection each time I ran it.
Can this be done with T-SQL or would I have to use the command window?
Thanks in advance. You guys are alway great 🙂
January 30, 2012 at 3:48 pm
jshahan (1/30/2012)
in order to completely refresh the query window
I don't understand what you mean with this. Can you please clarify?
-- Gianluca Sartori
January 30, 2012 at 3:53 pm
I mean that I want to re-initialize everything particularly the temporary tables. I know I can drop them etc. but I would prefer a clean disconnect, reconnect.
January 30, 2012 at 4:59 pm
No way to do this AFAIK.
You'd better DROP/CREATE all the temporary objects you are using, which is a best practice anyway.
-- Gianluca Sartori
January 31, 2012 at 6:22 am
Thanks for the response. 🙂
January 31, 2012 at 6:30 am
It's not exactly T-SQL, but can't you just put your query window in sqlcmd mode and use the :CONNECT command?
See here for examples: http://www.mssqltips.com/sqlservertip/2311/using-the-ssms-query-editor-in-sqlcmd-mode/
The query get executed on the server you name and then disconnects, so all temp objects will be dropped.
[font="Verdana"]Markus Bohse[/font]
January 31, 2012 at 6:38 am
Or right-click anywhere in the query window and choose Connection -> Disconnect. Then do the same, choosing Connection -> Connect.
John
January 31, 2012 at 7:34 am
It's not exactly T-SQL, but can't you just put your query window in sqlcmd mode and use the :CONNECT command?
See here for examples: http://www.mssqltips.com/sqlservertip/2311/using-the-ssms-query-editor-in-sqlcmd-mode/
Thanks Markus. This looks like the way I am going to have to go. I haven't used sqlcmd-moded before but it looks really straightforward and will probably help me a bit down the road as well.
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply