I had created identical databases in different environments: Dev and QA. While doing the development, I have changed a few tables in the Dev database. How do I change the QA database to make it again identical to the Dev database in terms of tables (and constraints)?
I checked the below link:
[Copy one database to another database
Steps in the above link did not directly work because the tables and constraints already existed in the second database. I did modification in the sql file after the steps
I followed the below steps:
- Right-click on the database you want to copy
- Choose 'Tasks' > 'Generate scripts'
- 'Select specific database objects' and Check 'Tables'
- Click on Next. Again click on Next.
This exports .sql file to the path shown while following the above steps.
I edited the script file and changed the database name to the QA database name (at the top of the script).
After this added the below line above every create table statement as the table exist.
DROP TABLE IF EXISTS tablename;
On running the query, I get an error message saying
Could not drop object tablename because it is referenced by a FOREIGN KEY constraint.
How do I change the second database to make it identical to the first database in terms of tables (and constraints)?
Thank You