HeavenCore | IT Solutions Built on Open Source Software
View Thread
 Print Thread
SQL Mirroring - Set Mirror Timeout
admin
Simple script to set mirror timeout on all mirror databases:


SET NOCOUNT OFF   

DECLARE @strSQL NVARCHAR(200)
DECLARE @strDatabasename NVARCHAR(50)
DECLARE @Cursor_CurrentMirrors CURSOR

SET @Cursor_CurrentMirrors = CURSOR FAST_FORWARD
FOR
   SELECT  name
   FROM    master.sys.databases a
         INNER JOIN master.sys.database_mirroring b ON a.database_id = b.database_id
   WHERE   mirroring_guid IS NOT NULL
OPEN @Cursor_CurrentMirrors   
FETCH NEXT FROM @Cursor_CurrentMirrors INTO @strDatabasename   
WHILE @@Fetch_Status = 0
    BEGIN   
        SET @strSQL = 'ALTER DATABASE [' + @strDatabaseName + '] SET PARTNER TIMEOUT 60'   
        EXEC sp_executesql @strSQL   
        PRINT 'Running: ' + @strSQL
        FETCH NEXT FROM @Cursor_CurrentMirrors INTO @strDatabasename   
    END   
CLOSE @Cursor_CurrentMirrors   
DEALLOCATE @Cursor_CurrentMirrors   

Jordon Pilling | Heavencore Administrator
 
Jump to Forum