Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Analyzer
Posting Yak Master
115 Posts |
Posted - 2013-09-16 : 12:27:36
|
Hi,Need to write a script that maps a proxy account (already created) to every database with database role db_backupoperator.Next problem is there are 200 sql instances (2000, 2005, 2008, 2012) so the syntax will be changing. The proxy account will always be the same but the instance name\databases will change of course. So would need to make the script generic to run within SQL Group Multi Query.Any ideas the most efficient method to complete this? |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
|
Analyzer
Posting Yak Master
115 Posts |
Posted - 2013-09-18 : 06:53:28
|
Hi - thanks for the direction.Next issue I have is supplying a variable in the command since this script will be run against 100s servers.Any ideas how I get sp_MSforeachdb to accept my variable. I have tried the below but it fails. Any ideas?DECLARE @sqlCommand VARCHAR(2000)declare @svr as varchar(30)set @svr = 'select @@servername'SET @sqlCommand = 'USE ; CREATE USER [@svr\shellLocalUser] FOR LOGIN [@svr\shellLocalUser];' EXEC master..sp_MSForeachdb @sqlCommand |
|
|
|
|
|