What's wrong with my SQL statement?

Occasional Contributor

I am trying to recover a database for a customer who has been depending on MS Dynamics for a long time. His Server 2003 data drive failed irrevocably, but he had a recent backup of his Server Essentials 2005 database. His C drive held the programs.

 

The object is to get his MS Dynamics working again so that he can add the transactions for the last month and then export all required tables to the company that's putting his company in the cloud (I don't know what the final interface might be but probably not Dynamics.)

 

On another computer, as a test, I recovered the .BAK file to a 2012 Server Essentials - but without reference to his original programs. So, I know that his tables and views exist (I am not a SQL Developer but a generalist, so his 200 tables are not something I know how to deal with).

 

Anyway, after creating a data drive and putting back all folder items backed up, I tried running the RESTORE command and got several errors. I'm going to skip the first try or so, because I've been figuring this out with the help of others.

So, I used the following:

RESTORE FILELISTONLY FROM DISK='D:\One Stop Backup\OSD_NOv8-2022.bak'

Results

GPSOSDDat.mdf D:\ONE STOP\MSSQL\GPSOSDDat.mdf
GPSOSDLog.ldf D:\ONE STOP\MSSQL\GPSOSDLog.ldf

Now I adjusted the script (I also created the folder D:\ONE STOP\MSSQL):

RESTORE DATABASE [OSD]
FROM DISK = 'D:\One Stop Backup\OSD_Nov8-2022.bak'
WITH MOVE 'GPSOSDdat.mdf' TO 'D:\ONE STOP\MSSQL\GPSOSDDat.mdf',
MOVE 'GPSOSDLog' TO 'D:\ONE STOP\MSSQL\GPSODLog.ldf',
REPLACE,
STATS=10
GO

Result:

Msg 3234, Level 16, State 2, Line 1
Msg 3013, Level 16, State 1, Line 1

The item 'GPSOSDLog' is the only item I made up in order to stay with the formula I found on this forum. It seemed that the formula used the name of the .LDF file without the extension. I don't know if this makes a difference. Also, it seems like the errors are about "Line 1" and OSD is the name of the database according to the dropdown in SQL Server Management Studio.

 

Any ideas as to what the problem might be?

0 Replies