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

Automate and integrate using the SQL comparison API

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

Postby aporter » Wed Oct 01, 2008 8:19 am

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.
Posts: 1
Joined: Wed Oct 01, 2008 8:14 am
Location: Malta

Postby Michelle Taylor » Tue Oct 07, 2008 10:28 am

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, I'll have a go at tracking down the problem for you.
Michelle Taylor
Posts: 535
Joined: Mon Oct 30, 2006 11:45 am
Location: Red Gate Software

Return to SQL Comparison SDK Previous Versions

Who is online

Users browsing this forum: No registered users and 0 guests