Registration fails because db has the same name
jprice2269
Posts: 9
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?
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
Redgate Software
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?
Redgate Software
e.g.New Engine.ConnectionProperties(_combinedServerName, databaseName)
This doesnt work either.