DBO User ISSUE

I've attached a database from one server to another and the dbo user is still located at the database level but i'm unable to give the sa user access to the database because it was already located at the db level.

I am also doing transactional replication and I'm getting this error:

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. (Source: MSSQLServer, Error number: 15517)

Anybody know a fix to this issue?
faclogisticsAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Aaron ShiloConnect With a Mentor Chief Database ArchitectCommented:
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>'

0
 
mcv22Commented:
The sa user might have been orphaned. Run the following command in the database.

Another option is to drop the sa user from the restored database and map it again (this will lose any explicit permissions assigned in that database).
exec sp_change_users_login 'auto_fix', 'sa'

Open in new window

0
All Courses

From novice to tech pro — start learning today.