Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 913423 - Last Review: February 14, 2006 - Revision: 1.2
You cannot run a statement or a module that includes the EXECUTE AS clause after you restore a database in SQL Server 2005
Bug #: 397455 (SQLBUDT)
When you run a statement or a module that includes the EXECUTE AS
clause in Microsoft SQL Server 2005, you may receive the following error message:
Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission.
This problem occurs when all the following conditions are true:
- You back up a database from an instance of SQL Server 2005. Then, you restore the database to an instance of SQL Server 2005 that is installed on another
computer.
- The statement or the module is executed as the dbo
(database owner) user.
- The owner of the database is a domain user or a SQL Server
authorization login.
Notes- If a domain user owns the database, the computer on
which you restore the database cannot access the domain.
- If a SQL Server authorization login owns the database,
the login does not exist in the new instance of SQL Server 2005.
This problem occurs because SQL Server 2005 cannot obtain the
information about the context when you try to impersonate a database user to
run a statement or a module.
SQL Server cannot obtain the information about the context that you are trying to impersonate under the conditions that are listed in the "Symptoms" section. If you impersonate a SQL Server authorization login, SQL Server cannot find a login that matches the security identifier (SID) of the impersonated user. If you impersonate a domain user, the domain controller cannot find the information about the specific user who matches the SID of the impersonated user.
To work around this problem, change the database owner to a
valid login or domain user. To do this, run the following statements:
USE <DatabaseName>
GO
sp_changedbowner '<NewLogin>'
Note <DatabaseName> represents the
name of the database.
<NewLogin> represents the name of the login that you want to set.
Microsoft
has confirmed that this is a problem in the Microsoft products that are listed
in the "Applies to" section.
APPLIES TO
- Microsoft SQL Server 2005 Standard Edition
- Microsoft SQL Server 2005 Developer Edition
- Microsoft SQL Server 2005 Enterprise Edition
- Microsoft SQL Server 2005 Express Edition
- Microsoft SQL Server 2005 Workgroup Edition
| kbsql2005engine kbprb kbexpertiseadvanced KB913423 |
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate