userSteve
userSteve

Reputation: 1644

Open multiple copies of same file in SSMS

We have a script file called CreateClientDatabase.SQL, double clicking it opens it in SSMS where we can change a few parameters and execute it.

Problem: A few hours/days later we may need to do the same again for another client, but if the original tab in SSMS has not been closed then double clicking the file will simply bring that tab to the fore and not actually open the file. So it's easy to assume the script you are now looking at is the same as the file when it is not, and this can lead to all sorts of issues.

Is there a way round this? Can SSMS open a second copy of the file, or warn the user that it hasn't actually opened it much like Excel does.

Upvotes: 3

Views: 610

Answers (3)

Andrei Rantsevich
Andrei Rantsevich

Reputation: 2935

What you need, I think, is something similar to excel or word template files: whenever you open such file by double-click, a new document with the contents of the template is created.

SSMSBoost add-in (that I develop) has “Autoreplacements” feature: you can define a “magic token”, that will be replaced by your script, whenever that token is typed. For example, we have pre-defined token “sel”, which is replaced by “select * from” whenever you type “sel” and press space. You could associate your script with any word, like “doit”, so whenever you visit next customer, you just open new query window, type that word+space and you have your script in the window immediately.

Just to mention: SSMSBoost allows you to define “favorite” connections, so, you can save all your cutomer’s servers in one list and quickly switch between them.

Alternative: Have a look at SSMS Templates (View->Template explorer). SSMS allows creating your own templates and opening them by double-clicking their name from Template Explorer. In connection with SSMSBoost “Preferred connections” list you have a good setup to start your work quickly.

Hope this helps.

Upvotes: 1

Alexei - check Codidact
Alexei - check Codidact

Reputation: 23078

I think what you need is to detect when the SQL script file is changed outside if the SSMS environment:

make sure that Tools -> Options -> Environment -> Documents -> Detect when file is changed outside the environment is checked.

More details can be found here.

Upvotes: 0

mahzar
mahzar

Reputation: 1

If file is opened from the windows explorer then it opens another instance of SSMS.

Upvotes: 0

Related Questions