Revoke CONNECT permissions

Removes the guest user permissions, excluding the master, msdb and tempdb, to connect to SQL Server user databases.

This code revokes the CONNECT permissions from the guest user in a database:

USE [database_name];
GO
REVOKE CONNECT FROM guest;