Options

Registration fails because db has the same name

jprice2269jprice2269 Posts: 9
edited February 14, 2008 8:46AM in SQL Toolkit Previous Versions
I have a database, which has been detached from the server, the files copied and then reattached.

The database on the server moves on in terms of structure.

Now, I need to compare the database on the server with the copy I got earlier.

I can register the current database, setting Database name as 'Source' no problem.

Toolkit wont let me attach (as an sqlexpress) the copy database, even setting Database name as 'Destination'. (will do if I do this first, but then the other fails)

Says cant attach as the database name is the same (the original name stored in the file) and appears to ignore the Database Name property.

Ideas?

Comments

  • Options
    I don't quite follow what you're trying to do - could you give an example of the code you're using to attach (register?) the second database?
    Software Developer
    Redgate Software
  • Options
    Start with a database file, FileName File1.mdf,

    Copy the file and call it File2.mdf.

    Both files are identical right now,


    File1.mdf is opened and is changed in some way,.


    Now the task is to determine the changes between File1 and File2

    Firstly need to register the two files.

    So,

    Register File1

    _combinedServerName = "Server=.\SQLEXPRESS; AttachDBFileName=File1.mdf; Database='Source'; User instance=true; pooling=false;"

    databaseName = "Source"

    _connectionProperties = New Engine.ConnectionProperties(_combinedServerName, databaseName)

    _connectionProperties.IntegratedSecurity = True

    m_db1.Register(_connectionProperties, m_engineOptions)

    This suceeds.


    Register File2

    _combinedServerName = "Server=.\SQLEXPRESS; AttachDBFileName=File2.mdf; Database='Dest'; User instance=true; pooling=false;"

    databaseName = "Dest"

    _connectionProperties = New Engine.ConnectionProperties(_combinedServerName, databaseName)

    _connectionProperties.IntegratedSecurity = True

    m_db2.Register(_connectionProperties, m_engineOptions)



    This fails with the error message

    Database 'FILE1.MDF' already exists. Choose a different database name.
    Cannot attach the file 'FILE2.MDF' as database 'Dest'.

    It is accessing the correct file (file2.mdf) but reading its internal name and not the given name Dest.

    Any ideas?
  • Options
    I think it's quite likely we don't support that kind of connection string - we don't support any of the special SQLEXPRESS connection strings, only straightforwards connections to live databases.
    Software Developer
    Redgate Software
  • Options
    But you do allow to specify a database name in your connectionProperties.

    e.g.New Engine.ConnectionProperties(_combinedServerName, databaseName)

    This doesnt work either.
Sign In or Register to comment.