3

In SSMS I have this

:SETVAR DBSrvrInst MyDatabase
:connect  ADMIN:$(DBSrvrInst)

In the Messages tab I get

Connecting to ADMIN:$(DBSrvrInst)...

The variable isn't being replaced. But if I do this and remove the constant

:SETVAR DBSrvrInst MyDatabase
:connect  $(DBSrvrInst)

In the Messages tab I get

Connecting to MyDatabase...

The variable is replaced correctly. How do I get this to work

:SETVAR DBSrvrInst MyDatabase
:connect  ADMIN:$(DBSrvrInst)

I would even be ok with using the port but that doesn't work either

:SETVAR DBSrvrInst MyDatabase
:connect  $(DBSrvrInst),1434

Any suggestions are greatly appreciated.

2

How about just placing the ADMIN: text in the variable? eg

:setvar DBSrvrInst ADMIN:.\sql2014

:connect $(DBSrvrInst)
GO
  • That would work, but my goal is to connect using the Dedicated Admin Connection to kill some processes using a workload group. Then drop the workload. And then reconnect not using the DAC. – AWEInCA Jan 3 '16 at 5:22
  • You did give me an idea to just use two variables. The additional one having the ADMIN: prefix as you suggested. That will probably work, but it seems strange the token replacement for :connect ADMIN:$(DBSrvrInst) doesn't work. I'll mark your answer correct after I have a chance to try this. Thanks for your reply. – AWEInCA Jan 3 '16 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.