- Newest
- Most votes
- Most comments
In case, you can't change the owner, then you need to create an intermediate or temporary EC2 SQL Server restore the database there and edit the owner and then take backup again for the restore to RDS SQLServer
The error suggests that principal dbo (database owner) doesn't exist
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.
Check the Database owner of the DB on on-premises using sp_helpdb <database name>
if it is blank, then add an existing user which is Sysadmin like 'sa' to be the owner of the database by modifying it in the DB properties
if it not blank, You can create the same login in the RDS SQLServer with same permissions as master user [1] After performing this, take a backup and restore with TDE restore process.
Reach out to support if this doesn't help.
[1] https://repost.aws/knowledge-center/rds-sql-server-clone-login-permissions
The first part of the suggested solution is a common suggested solution I saw elsewhere. However, it cannot be applied. There is no database to change the owner on. (It temporarily exists during the restore operation. Trying to change the owner while the restore is in progress is prohibited. When the stored procedure fails, the database is removed). Also, the msdb.dbo.rds_restore_database does not work on existing databases so it is not possible to create an empty database and set the owner.
Thanks you for the provided link. I will ask my client to run and provide me with the resulting script and see if that helps...
Relevant content
- asked 2 years ago
- asked a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 7 months ago
I was able to spin up a Windows instance with SQL Server. It took a little time to resolve the import on that instance. However, even exporting from there with owner set, I still got the original error on restore to RDS. For my purposes, I will just use my windows instance since this is a short term project.
For those who come across this in the future, I was not able to resolve the original error.