What are the challenges you face when working across database platforms? Take the survey

User, group, or role 'dbo' already exists...

aporteraporter Posts: 2
We are currently doing an evaluation on your SQL Comparison SDK.

We are encountering an issue when executing the following piece of code. We are getting stuck with an exception which we cannot get around for the time being.

The exception below is being raised only when the source database structure is loaded from a file using the code below.


We appreciate your help on this issue please.

Thanks a lot for your help.



private void ExecuteBlock(ExecutionBlock block, Database database_Destination)

//Step 4. Run Script
BlockExecutor executor = new BlockExecutor();

executor.ExecuteBlock(block, database_Destination.ConnectionProperties.ServerName, database_Destination.ConnectionProperties.DatabaseName, false, database_Destination.ConnectionProperties.UserName, database_Destination.ConnectionProperties.Password);

…gives the exception detailed below on the above statement

catch (Exception exception)
throw exception;


- exception {"User, group, or role 'dbo' already exists in the current database."} System.Exception {System.Data.SqlClient.SqlException}

StackTrace " at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)\r\n at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)\r\n at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)\r\n at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)\r\n at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async)\r\n at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)\r\n at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()\r\n at RedGate.Shared.SQL.ExecutionBlock.BlockExecutor.ExecuteBlock(ExecutionBlock block, String server, String database, Boolean integratedSecurity, String userName, String password)\r\n at Exigy.SystemFramework.General.SQLDataBase.RedGateUtils.DataBaseCompareUtil.ExecuteBlock(ExecutionBlock block, Database database_Destination)" string

Any help to what this error exactly means would be greatly appreciated.


  • Options
    The error means that the script that was generated by the SDK is trying to create the 'dbo' user.

    This shouldn't be happening, but has been previously known to happen with schema synchronization from snapshots.

    If you could give a bit more information about how you're generating the script in the first place (what's the other database, what version of Compare did you use to create the snapshot, what SQL Server versions are involved, are you using any non-default options, what's the case sensitivity of the databases in question and the servers they're on), and ideally send me a copy of the troublesome snapshot (to michelle.taylor@red-gate.com), I'll have a go at tracking down the problem for you.
    Software Developer
    Redgate Software
Sign In or Register to comment.