????????????а???
????????????????
--=================================
--???????
SELECT  DB_NAME([database_id]) as 'dbname'??* FROM sys.[database_mirroring]
GO
ALTER DATABASE [test] SET PARTNER OFF
ALTER DATABASE [test] SET WITNESS OFF
--=================================
--???????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER RESUME
GO
--=================================
--??????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER SUSPEND
GO
--===================================================
--δ??????????δ????????????
WITH tmp AS(
SELECT
DB_NAME(Database_id) AS DatabaseName??
ROW_NUMBER()OVER(PARTITION BY Database_id ORDER BY local_time DESC) AS RID??
*
FROM msdb.dbo.dbm_monitor_data
)
SELECT *  FROM tmp
WHERE RID=1
--?????redo_queue ??send_queue
--=================================
--???????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER OFF
GO
--=================================
--????????????
USE [master]
GO
ALTER DATABASE [Demo1] SET WITNESS OFF
GO
--=================================
--????????????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER SAFETY OFF
GO
--=================================
--??????????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER SAFETY FULL
GO
--=================================
--?????????????????????????????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER FAILOVER
GO
--=================================
--??????????????????????????????????????????????
--??????????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS
GO
--=================================
--??????????????????
--?羵??????????????????????????????????????????SQL?????????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER RESUME
GO
--=================================
--???????????????????????
USE [master]
GO
RESTORE DATABASE [Demo1] WITH RECOVERY
GO
--=================================
--??????????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER SAFETY FULL
GO
--=================================
--??????????????????????????????????????????????
--??????????
USE [master]
GO
ALTER DATABASE [Demo1] SET PARTNER FORCE_SERVICE_ALLOW_DATA_LOSS
GO