My project had 2 companies which have different data set though their parent Organization is same. Thus, we had dedicated UAT/PPD/REF machines for each company. Though the developers check in against the same dev branch, in order to test their changes which are company specific, we initially had seperate dev boxes.
Can we have both databases in our SQL and swap it based on the dataset we need.
Create a new DB and name it based on the company dataset. Let`s say AxDB_1. Import the data in this db using import command. Steps given below
In the command prompt , change the path to “cd C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin”.
SqlPackage.exe /a:import /sf:D:\Exportedbacpac\Backup.bacpac /tsn:devBocName /tdn:TargetDBName /p:CommandTimeout=1200
Usually our existing db name would be AxDB. If you need to use the imported database, rename the original Db and change the imported db to AxDb.
It is not possible to directly rename the db. Commands given below
USE [master];GOALTER DATABASE AxDb SET SINGLE_USER WITH ROLLBACK IMMEDIATE;GOEXEC sp_renamedb N’AxDb’, N’AxDb2′; ALTER DATABASE AxDb2 SET MULTI_USER WITH ROLLBACK IMMEDIATE;
Use the above command to rename AxDb_1 to Axdb.
7. Reset IIS and now the new db is ready with another dataset.
If you need to change to AxDb2, use the commands mentioned in 5 and 6.