[SQL Server] Some Ideas about error 15517

Source: Internet
Author: User

When you detach a database and attach it to another computer, the following error may occur: when a user with limited permissions executes some stored procedures, error 15517 may occur: it cannot be executed as a database entity because the entity "DBO" does not exist, you cannot simulate this type of entity, or you do not have the required permissions.

The stored procedure that causes this error has a with execute as option, specifying the owner or another user (login name ).

For example, I used Windows authentication to log on to my computer, created a database, and created a stored procedure with the with execute as owner option in the database. Then, separate the database and attach it to another user's computer. If you run the stored procedure, the above error will be thrown.

This error occurs because the user (login name) specified by the with execute as option does not exist on the current server. When I use Windows authentication to log on to the server and create a database, the database owner is the Windows account I use. When a stored procedure is executed on the local machine, SQL Server finds the user and executes the stored procedure as the user. However, when the database is attached to another computer, the system of that computer does not have this account on my computer, and the user cannot be found during the execution of the stored procedure, therefore, an error is thrown.

To solve this error, modify the database owner. For example, run the following command:

 

Alter   Authorization   On   Database :: [ <Database's name ]   To   [ SA ]

Change the owner of the specified database to sa. Sa exists on all SQL Server servers, so the preceding error is not displayed.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.