By default the database files will be restored to the directories from which they came
On computer A I Created a Bak file
c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\aaa.mdf
Im going to computer B ( trying to restore the bak file ) ( to its D drive which contains its SQL folders)
and type : ( the folders are appropriate to the Computer B‘s folders).
RESTORE DATABASE aaa FROM DISK = '\\dsmain\OLD_DB\aaa.bak'
WITH REPLACE , MOVE 'aaa' TO 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\aaa.mdf',
MOVE 'aaa_log' TO 'D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\aaa_log.ldf'
ALTER DATABASE aaa SET MULTI_USER
Result :
https://i.stack.imgur.com/lD8u3.jpg
Even if i go to SMMS :
https://i.stack.imgur.com/pIpC7.jpg
I can see that he’s searching his ORIGINAL PATH.
Question :
How Do I tell him programmatic , not to restore as its original location but my location ?
1 Answer