Sql-server – Cannot execute as the database principal because the principal “guest” does not exist

connectivitypermissionssql server

Recently moved SQL Server from a desktop to a virtual machine and now facing the below error message while connecting to SQL Server using SQL Authentication.

-2147205987:[Microsoft][ODBC SQL Server Driver][SQL Server]Cannot execute as the database principal because the principal “guest” does not exist, this type of principal cannot be impersonated, or you do not have permission.

The user ID SQLADMIN is used to connect to SQL Server.

May I know the permissions that SQLADMIN should have to do a BULK_COPY operation along with normal functions?

Currently SQLADMIN is set with the PUBLIC and BULKADMIN permissions. For Database1 and Database2 (used in the project), SQLADMIN is given PUBLIC and db_OWNER permissions.

After these changes, I am still facing the same issue.

Best Answer

I have not needed to overcome this problem on a SQL Server except when I make a mistake with permissions. I do not endorse the below, because I have not spent time on the problem.

However, for what it is worth, Symantec has an article on this issue using SQL Server 2012 and Windows 2012 at:

Cannot execute as the database principal because the principal “guest” does not exist

Their answer is based on how your SQL Server is configured.

  1. A default instance running under Local System should run under NT Service\MSSQLServer, then NT Authority\System has db_datareader role to the “master” database.

  2. A named instance running under Local System should run under NT Service\MSSQLServer or NT Service\MSSQL$ServerXInstanceX, then ONLY NT Authority\System has db_datareader role to the “master” database.

  3. If running under Domain or Local user account the instance should run under Mydomain\MyUser, then Mydomain\MyUser has “db_datareader” role to the “master” database