I am trying to use
sp_DatabaseRestore from the SQL Server First Responder Kit to restore some databases. It works fine if I first restore the database in a normal way using SSMS, but if the database does not previously exist, it says that it could not find the file specified (for both data an log-files).
It also ends with the following message:
The database "DatabaseName" does not exist. RESTORE can only create a database when restoring either a full backup or a file backup of the primary file.
But the first path is for the full backup, so I am not sure what this means.
Is there some particular use of the parameters that would help me use this even when the database does not exist, or am I forced to create them first?
Any suggestions appreciated.
Edit: Code that is used (paths and names have been changed). The code fails if the database does not exist. If I create the database, then it works:
DECLARE @VersionDate datetime; EXEC dbo.sp_DatabaseRestore @Database = N'DatabaseName', @BackupPathFull = N'\\SERVERNAME\Backup\servername-wfcs$ServerNameAG01\DatabaseName\FULL\', @BackupPathLog = N'\\SERVERNAME\Backup\servername-wfcs$ServerNameAG01\DatabaseName\LOG\', @MoveFiles = 0, @ContinueLogs = 0, @RunRecovery = 1, @ForceSimpleRecovery = 0, @Debug = 0, @VersionDate = @VersionDate OUTPUT
Edit 2: Turns out there was a difference in the data-file folder names between the old and the new server. The old server had a version-number lower than the actual version of the SQL Server, probably due to an earlier in place upgrade. When trying to restore from a backup with correct data folder, there is no problem.