Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server Management Studio: Reconnect query tab after database restore/lost connection

I have several long queries in SQL Server Management Studio. If my connection is lost/broken (e. g. after Restore of the database), how can I reconnect my SQL query tab to the database? My context menu for the connection only contains deactivated items...

It is not too much work to copy everything, open a new SQL query tab on my database and paste it, but "smart" is something completely different.

like image 553
Mate Avatar asked Aug 11 '16 12:08

Mate


4 Answers

Just click "Execute" and it will reconnect again.

like image 103
energyguy78 Avatar answered Oct 20 '22 04:10

energyguy78


After reconnecting the database - as described here - you must still select your database from "available databases" pull down menu. Then your queries start to work

like image 9
Tikke Avatar answered Oct 20 '22 02:10

Tikke


Click the 'Change Connection' icon and it will allow you to reconnect back to the DB

like image 2
Peter Avatar answered Oct 20 '22 02:10

Peter


I see this happening only when I use F5 for the execution of the script and I get error. Only then the connection options are disabled for some reason.

Anyway the solution to this state is clicking the Execute button (or context menu button if you right click) as energyguy78 suggested. That should re-connect the tab.

like image 1
Adam Kolařík Avatar answered Oct 20 '22 03:10

Adam Kolařík