guest User

Administering SQL Server

Administering SQL Server

guest User

The guest user account allows a login without a user account to access a database. A login assumes the identity of the guest user when both of the following conditions are met:

  • The login has access to an instance of Microsoft® SQL Server™ but does not have access to the database through his or her own user account.

  • The database contains a guest user account.

Permissions can be applied to the guest user as if it were any other user account. The guest user can be deleted and added to all databases except master and tempdb, where it must always exist. By default, a guest user account does not exist in newly created databases.

For example, to add a guest user account to a database named Accounts, run the following code in SQL Query Analyzer:

USE Accounts
GO
EXECUTE sp_grantdbaccess guest

To grant a SQL Server login access to a database

Transact-SQL