I am trying to restore a backup of our Production Database to our Test environment, and receive the error "A content database with the same ID already exists on the farm." after the restore operation completes.
After attaching the new Database to the new application I created for it, I cannot pull up the site.
How can I remove this duplicate ID? I believe the offending ID is in the SP_Config database's SiteMap table, but i am unsure if I should be removing anything from here. We also have a full test content DB that cannot be touched.
Has anyone else had this issue?
Have you done this backup/restore previously from the PROD to TEST farms?
You may need to delete the previous content database from the TESTfarm if that is the case.
Related
I have a Database project for my personal project and I am trying to deploy my code to my DEV server. I frequently delete and re-create my DEV Server. Right now, DEV Server is newly created with SQL Server. Every time I want to deploy my code I have to manually create Database Project and then publish database project. I want to automate creation of Database with database project deployment.
Right now, I have a script that creates database, but I have to execute it manually. And this is working perfectly but I want to automate this step as well.
Is this even possible? If yes, then how? Please explain step by step. Also what will we mention for Initial Catalog in connection string?
Edit:
I tried to create Database by using
CREATE DATABASE LocalDbTest
in Pre-Deployment Script. But it didn't work. It is creating Database, but then tables are not getting created tables under it. Since I used master database as default database, it is creating table under master. It is not letting me select LocalDbTest database as default because it is not yet created, so I have to select Master as my default database. I tried to Change Database by:
USE LocalDbTest
GO
I used it just after creating Database but this didn't work because when generating script it is changing back to default database. This part is coming automatically when generating script.
USE [$(DatabaseName)];
GO
Also Visual Studio is not letting me add database name in front of table name like:
CREATE TABLE [LocalDbTest].[dbo].[TestTable]
I am getting error:
When you create an object of this type in a database project, the object's name must contain no more than two parts.
If you have a script ready for database creation, you can use the Pre-build event to call SQLCMD and run your script.
Edit:
If you have trouble pointing to a database that does not exist, you may have to manually edit the publish profile (ex. dev.publish.xml) and set the TargetDatabaseName element explicitly. You can also set CreateNewDatabase element to True if you want to be recreated every time it gets published.
Answer:
You can use a publish profile and hardcode the target database in it.
I'm using Visual Studio 15.8.5 with Sql Server Data Tools 15.1.
I've created an SQL Server database project and imported the schema of an already existing database. I've made several minor changes to a few tables of the database and published the updates to the development database without any problems.
After adding a few SQL scripts to the project, all of them with:
Build Action = None
publish fails, despite no changes have been made in any of the database objects of the project.
This is the part of the auto-generated publish script that causes the problem:
/*
The table [lut].[KAE] is being dropped and re-created since all
non-computed columns within the table have been redefined.
*/
IF EXISTS (select top 1 1 from [lut].[KAE])
RAISERROR (N'Rows were detected. The schema update is terminating
because data loss might occur.', 16, 127) WITH NOWAIT
GO
Table [lut].[KAE] has not been changed, though. One of the scripts is redefining its schema but this should make no difference since this is a 'No Build' script.
What am I possibly doing wrong here?
Edit:
I've done a schema comparison as #MadBert advised. I originally used my actual database as source and my sql server visual studio project as target. No differences were found.
I then switched source and target databases and compared again. The following 'difference' was detected.
As you can see this is not an actual difference, it looks like a Visual Studio bug in schema comparison. Any ideas on how I could circumvent this behavior?
It turned out that a refactor log file was the culprit.
I tried to publish to an empty database, as #Ogglas wisely advised. I noticed that during publish I was getting the following message:
The following operation was generated from a refactoring log file
8e659d92-10bb-4ce9-xxxx-xxxxxxxxx Rename [lut].[KAE].[xxxxx] to
$$$$$$$$$ Caution: Changing any part of an object name could
break scripts and stored procedures.
I then noticed that my SQL Server Database project contained a .refactorlog file
It seems that this log file was generated after I changed the offending table schema. The schema of the table was later reverted to its original state but the log file remained.
I deleted this log file and after that publish finally succeeded!
Had a similar problem when a SQL Server Database project was set to the wrong Target platform. Edit this in project properties to match the target server. Initiate a schema compare again by right clicking on the project and select Schema Compare....
Also check if Ignore whitespace is marked in Schema Compare Options. If you still have a difference one way or another try pasting the text in Notepad++ with Show All Characters on and see if you can spot a difference.
If you still can't find any difference, try creating a new database from the project and use SSMS GUI to compare. Does the table have the same Lock Escalation settings etc?
I want to create a copy of my sql server 2008 r2 database (named ERP) inside the same machine. so I did the following steps:-
I right click on the original database ERP and I select Tasks>>Backup.
then I create a new empty database named "ERP_Copy".
I right click on the ERP_Copy database, then select restore>>database.
inside the restore options I define the To to be ERP_Copy and the From to be ERP.
then I click to start the process, but I got the following error :-
so can anyone advice on these 2 questions:-
what is causing this error ?
could my original database ERP got corrupted or modified due to the error ?? or my ERP should not be modified by my above operation and the error I got ?
Thanks
the error is as stated in the message: you are restoring on a target database that is not the one used as the backup source.
To solve and complete the restore, start the restore, go to the Options page and tick the Overwrite the existing database (WITH REPLACE) checkbox.
DOUBLE CHECK source and destination database because the above checkbox would completely smash your production db if you make the wrong choices...
The original database has not been altered by the first (failed) operation.
I have made an SQLite database file with some testdata in it. When I use it in my application it goes well.
Next I have inserted a new row with data into my table with an SQLite manager. Here's where the problem is. When i run my application now, the new data doesn't appear. It's still all the old data (without the newly inserted one).
Does anyone know why the SQLite file isn't updated (Or maybe it's updated but doesn't show the data)?
Update:
I use the SQLite manager in FireFox.
I've inserted it with that manager, and when i query the select * from table it shows the new data.
I use the following command to open my database
var db = Titanium.Database.install('../test2.sqlite', 'test');
What is the current path when you open the database? ../ refers to the parent folder; are you absolutely certain that is the same folder where you’ve been creating a database using SQLite Manager? SQLite doesn’t error out if you open a non-existing database; it’ll just create a new, empty, one.
Use a full, absolute path, and try again.
this is typically i think. your database seems to be cached. you should change the name
var db = Titanium.Database.install('../test2.sqlite', 'test_v2');
or delete the cached database.
You don't need to rename your database.
You can try to delete the app in your simulator or emulator and install the app again. It worked for me. Since the app still has the old database. Re-installing the app with the new data (i.e. columns, rows). I use SQLite Manager plugin in Firefox as well.
I HAVE to be missing something really simple here!
I have a database in my development environment called Project.
I have a database in my test environment called Project_UAT.
I've created an SSIS package that successfully copied my database from Project to Project_UAT. I'm pretty sure this eliminates most permission and configuration issues.
Now, I want to re-create the package and this time allow it to overwrite the destination, which is Project_UAT. This is simply because from time to time I want to click a button in the Microsoft SQL Management Studio that pushes the new database schema, data, users, and everything, out to my testing environment. I WANT to overwrite the data.
So I create the package just like I did before, but this time I specify the already-existing database name as the "Destination database" and I select the radio button called "Drop any database on the destination server with the same name, then continue with the database transfer, overwriting existing database files."
I click Next, and what does it tell me?
"Database name already exists at destination"
Well, I KNOW! I just told you I want to overwrite it!
How do I make this work?
Not sure if I am missing the point but why do you not use a task to drop/delete the existing database prior to your deployment step?
Perhaps you could qualify the SSIS Component Tasks you are using within your SSIS package.
Cheers, John
You can add an Execute SQL Task into the Control Flow to drop the database. Just set the SQLStatement property to
DROP DATABASE Project_UAT
After this step is executed the new copy of the Project_UAT database won't have to overwrite the old one.
I had this problem because I deleted the database before hand. The database is not in the destination folder, but SQL Server 2008 still thinks it is there. Refresh didn't work. And SQL Server wouldn't honor the selection of "Drop any database on the destination server..." It just complained that the database already existed.
Guys this is a common sense solution. A lot of complexity for nothing.
Backup the destination database you want to copy to and delete the destination database.
Open the copy database wizard and follow the steps.
Use the detach and attach method.
When you get to the configure destination database use the option if destination database exists select drop database on destination server with same name.
Now it will continue to the next screen.
But this only works if you delete the destination database first before starting the wizard.
I may have missed something but this worked for me.