Microsoft SQL Server 2005 database mirroring statements:
SERVER 1
CREATE ENDPOINT DbMirroring
STATE=STARTED
AS TCP(LISTENER_PORT=5023)
FOR DATABASE_MIRRORING(ROLE=PARTNER,ENCRYPTION=SUPPORTED)
ALTER DATABASE AdventureWorks SET PARTNER='TCP://192.168.5.106:5022'
SERVER 2
CREATE ENDPOINT DbMirroring
STATE=STARTED
AS TCP(LISTENER_PORT=5022)
FOR DATABASE_MIRRORING (ROLE=PARTNER,ENCRYPTION=SUPPORTED)
ALTER DATABASE AdventureWorks SET PARTNER='TCP://192.168.5.106:5023'
Witness server
CREATE ENDPOINT DbMirroring
STATE=STARTED
AS TCP (LISTENER_PORT=5033)
FOR DATABASE_MIRRORING (ROLE=WITNESS,ENCRYPTION=SUPPORTED)
ALTER DATABASE AdventureWorks SET PARTNER='TCP://192.168.5.106:5033'
You can set the mirror server as the principal server and the principal server as the mirror server by executing the following code:
USE MASTER
Go
ALTER DATABASE AdventureWorks SET PARTNER FAILOVER
Go