How to Add or Replace the Witness in a SQL Server Database Mirroring Session

Transact-SQL:
If you want to replace the Witness in a SQL Server database mirroring session using T-SQL, you can remove the existing Witness first by running this code from either database mirroring partner:

ALTER DATABASE [Database_Name] SET WITNESS OFF

Before you set a mirroring Witness, create an endpoint for database mirroring on the witness server instance, and grant connect permissions on the witness mirroring endpoint to login account of partner instances. On each of the partner server instances grant connect permissions on mirroring endpoint to login account of witness instance. On the principal server, run this code to set the new Witness (in this example database name is AdventureWorks, the Witness address is WTNSRVR, the witness database mirroring endpoint is 5024):

ALTER DATABASE AdventureWorks
SET WITNESS = 'TCP://WTNSRVR:5024'
GO

SQL Server Management Studio:
To add or replace the Witness in a SQL Server database mirroring session from SQL Server Management Studio:

Connect to the principal server instance -> Right-click the database -> select Tasks -> click Mirror:

database_tasks_mirror

Click 'Configure Security':

mirroring_configure_security

Click 'Next' in the Welcome screen.

In the Include Witness Server screen, click 'Yes', and then click 'Next':

mirroring_include_witness_server

Check 'Witness server instance' in the check box in the 'Choose Servers to Configure' screen and click Next:

mirroring_choose_servers_to_configure

In the 'Principal Server Instance' screen, don't make changes and click 'Next':

mirroring_principal_server_instance

In the 'Witness Server Instance' screen, click 'Connect' and Connect to the witness server instance:

mirroring_connect_to_server

In the 'Witness Server Instance' screen, the listener port and database mirroring endpoint of the witness server instance will be displayed. Click 'Next':

mirroring_witness_server_instance

In the 'Service Accounts' screen fill the fields for the domain service accounts (in this format: DOMAIN_NAME\user_name) if the witness uses a different service account from either of the partners. If all servers use the same service account, leave the fields blank ans click Next:

mirroring_service_accounts

in the 'Complete the Wizard' screen, click 'Finish':

mirroring_complete_the_wizard

Click 'Close' in the 'Configuring Endpoints' screen when it has finished configuring:

mirroring_configuring_endpoints

To confirm the change click 'OK':

mirroring_witness_added