August 18, 2011 at 1:09 pm
I want to run the below same query for 50 databases
How could we do that in single step instead of doing per database?
use [WSS_Content]
if not exists
(select * from sys.symmetric_keys
where name = N'##MS_DatabaseMasterKey##')
create master key encryption by password = N'Admin Key Password !2#4'
thanx
August 18, 2011 at 1:22 pm
pshaship (8/18/2011)
I want to run the below same query for 50 databasesHow could we do that in single step instead of doing per database?
use [WSS_Content]
if not exists
(select * from sys.symmetric_keys
where name = N'##MS_DatabaseMasterKey##')
create master key encryption by password = N'Admin Key Password !2#4'
thanx
I'm assuming the databases reside all on the same server?
Kurt
Kurt W. Zimmerman
SR DBA
Lefrak Organization
New York, NY
http://www.linkedin.com/in/kurtwzimmerman
August 18, 2011 at 2:04 pm
look at stored proc sp_msforeachdb
August 18, 2011 at 2:18 pm
i think something like this would be better than sp_msForEachDB:
I prever to generate possible statements, review and prune,a nd then run them when I'm ready
/*
USE SandBox; create master key encryption by password = N'NotARealPassword'
USE Waffle; create master key encryption by password = N'NotARealPassword'
USE Waffle2; create master key encryption by password = N'NotARealPassword'
USE Sunrise; create master key encryption by password = N'NotARealPassword'
*/
SELECT
'USE ' + NAME + '; create master key encryption by password = N''NotARealPassword'' '
FROM sys.databases WHERE database_id > 4
Lowell
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply