After the SQL Server peer replication configuration fails, it cannot be deleted and rebuilt. The error "cannot execute as the Database Principal because the principal" is returned.

Source: Internet
Author: User
Tags mssqlserver

During database migration, SSMs is used to perform view operations. However, after the view migration is complete, configure peer-to-peer replication. In the last step, an error is reported, and the subscribed part is not created successfully.

For example:

There is no way to delete the peering replication and recreate it, but an error is returned when deleting it: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.

I checked the information on the Internet and consulted my colleagues and found it was Microsoft's bug: http://social.msdn.microsoft.com/forums/en-US/sqltools/thread/91a27e23-c760-4ac1-80f4-0fac220c1adb/

This is a known issue when attaching a database through SSMs using a login which is not SysAdmin, one hits this error.

The workaround for this currently is to use T-SQL to attach database.

Create Database [databasename] On

(Filename = n'c: \ Program Files \ Microsoft SQL Server \ mssql10.mssqlserver \ MSSQL \ data \ databasename. MDF '),

(Filename = n'c: \ Program Files \ Microsoft SQL Server \ mssql10.mssqlserver \ MSSQL \ data \ databasename_log.ldf ')

For attach

After executing the following script, you can delete it:

Use [xxxx]
Go
Exec DBO. sp_changedbowner @ loginame = n 'sa ', @ map = false
Go

You can use a view or the following script to delete a copy:

Eclare @ publication as sysname
Declare @ publicationdb as sysname
Set @ publication = n' topusa'
Set @ publicationdb = n' topusa'

-- Remove the publication.
Use [topusa]
Exec sp_droppublication @ publication = @ publication;

-- Remove replication objects from the database.
Use master
Exec sp_droppublication
@ Dbname = @ publicationdb,
@ Optname = n'publish ',
@ Value = n' false'
Go

 

For detailed steps for peering replication deletion, see the link: http://msdn.microsoft.com/en-us/ms151256 (SQL .90). aspx.

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.