USE Master
GO
--  Sprawdzanie, czy istnieje punkt końcowy potrzeby do tworzenia kopii lustrzanych
IF NOT EXISTS(SELECT * FROM sys.endpoints WHERE type = 4)
CREATE ENDPOINT DBMirrorEndPoint
STATE=STARTED AS TCP (LISTENER_PORT = 4040)
FOR DATABASE_MIRRORING ( AUTHENTICATION = CERTIFICATE WitnessServerCert, ENCRYPTION = REQUIRED
                        ,ROLE = ALL
                       )
