Here are the steps below to imort the .bacpac file to the sql server.
Every time you import the .bacpac file, it will always create a new database on the sql server.
Step-1: Run command prompt as administrator and write the following command in it.
"C:\Program Files (x86)\Microsoft SQL Server\140\DAC\bin\SqlPackage.exe" /Action:Import /SourceFile:"J:\AXDB_UAT.bacpac" /tsn:dev630a58c756-1 /tdn:SSProd /p:CommandTimeout="0"
Here:
tsn is target server name
tdn is target database name
New database created successfully here.
Step-2: Now rename previous database and set newly created database named as "AxDB" after stopped following services.
World wide web publishing service
Management Reporter 2012 process service
Microsoft Dynamics 365 Unified Operations: Batch Management Service
Microsoft Dynamics 365 Unified Operations: Data Import Export Framework Service
OR
you can rename the database by using following commands:
Set database to single user
ALTER DATABASE dbName
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
Rename database
ALTER DATABASE dbName MODIFY NAME = dbNewName
Set database back to multiuser
ALTER DATABASE dbName
SET MULTI_USER WITH ROLLBACK IMMEDIATE
Step-3: Start the following services
World wide web publishing service
Management Reporter 2012 process service
Microsoft Dynamics 365 Unified Operations: Batch Management Service
Microsoft Dynamics 365 Unified Operations: Data Import Export Framework Service
Step-4: Now run db sync using the below command
K:\> AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe -bindir "K:AosService\PackagesLocalDirectory" -metadatadir K:AosService\PackagesLocalDirectory -sqluser username -sqlserver sqlservername -sqldatabase AxDB -setupmode sync -syncmode fullall -isazuresql false -sqlpwd password
Done!