I have created a backup of database A1234
as file A1234.bak
.
I want to restore this A1234.bak
in 2 different databases say D1 and D2 in same sql server instance.
I want same data in both the databases.
I've tried
RESTORE DATABASE D1
FROM disk='C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Backup\A1234.bak'
This works for D1. When I try for D2 It gives error that A1234 is already created and cannot be overwritten.
when I see in C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\
location, there is database A1234.mdf and A1234_log.ldf files and no D1.
while in SSMS it shows D1 and no A1234.
So I guess the database A1234 is just pointed to D1.
How can I just restore the schema and data in any database I want using .bak file.
I've seen some WITH MOVE
commands but can't understand it
Edit : Also Tried like this
RESTORE DATABASE D1 FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\Backup\A1234.bak'
WITH MOVE 'A1234' TO 'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\D1.mdf',
MOVE 'A1234_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL14.MSSQLSERVER\MSSQL\DATA\D1_log.ldf',
GO