Happy Holidays to the Kingdom! I know many will be going on vacation so I wanted to do an easy post that wouldn’t break anyone’s brain. Also, I am having problems with my brain and have been having tests done so mirroring just seemed to fit today. When it first appeared, I didn’t see much use for it, but now that I use it often, I love it. So Fail over that magic mirror. This script assumes the default configuration port of 5022.
You can check your endpoints this way:
select @@SERVERNAME, * from sys.endpoints
go
Here is how you would create an endpoint if it didn’t already exist.
select @@SERVERNAME, * from sys.endpoints
go
CREATE ENDPOINT Mirroring
STATE=STARTED
AS TCP (LISTENER_PORT=5022)
FOR DATABASE_MIRRORING (ROLE=PARTNER)
go
This is how you would fail over or fail back to a database.
:connect
ALTER DATABASE SET PARTNER FAILOVER
Finally, if you want to bring a previously mirrored database online this is super simple.
Restore Database With Recovery;
Love your magic mirror and it will love you too! Happy Holidays to all!