Execute on Principal
======================
Declare @string sysname
declare Mirror_cursor cursor fast_forward
for
select [name] from sys.databases where database_id >4 order by name
open Mirror_cursor
declare @dbname sysname
Fetch next from mirror_cursor into @dbname
while (@@fetch_status <> -1)
begin
set @string =(SELECT isnull(mirroring_role_desc,'NOTINMIRRORING') FROM sys.database_mirroring WHERE database_id = DB_ID (@dbname))
if @string ='PRINCIPAL'
begin
set @string = 'ALTER DATABASE ' + '[' + @dbname + ']' +' SET PARTNER FAILOVER'
print @string
exec( @string)
end
else
begin
print @dbname + ' ->' + @string
end
set @string =''
fetch next from mirror_cursor into @dbname
end
close mirror_cursor
deallocate mirror_cursor
No comments:
Post a Comment