patternModerate
Specify Connection in Management Studio T-SQL Query
Viewed 0 times
sqlquerystudiomanagementspecifyconnection
Problem
When adding users are roles to DB servers I often use the "Script this action" function from the GUI. I then just go to "Connection :: Change Connection" to do the same on my other servers.
Is there a way I can specify the connection in the scripted action so I don't have to do that second Change Connection step?
Is there a way I can specify the connection in the scripted action so I don't have to do that second Change Connection step?
Solution
No way to do this as part of a script from SSMS, but you do have two options.
One thing you can do is use SQLCMD mode and the ::connect command in order to have a script that will connect to multiple servers and run the script. This works well if you save the script for the user and use the :r command to load the script from a file.
Another thing you can do is configure a Central Management Server and then run your script against multiple servers at once.
One thing you can do is use SQLCMD mode and the ::connect command in order to have a script that will connect to multiple servers and run the script. This works well if you save the script for the user and use the :r command to load the script from a file.
Another thing you can do is configure a Central Management Server and then run your script against multiple servers at once.
Context
StackExchange Database Administrators Q#1853, answer score: 12
Revisions (0)
No revisions yet.