Thema: Delphi MSSQL DB Restore Problem

Einzelnen Beitrag anzeigen

Pet04

Registriert seit: 26. Sep 2007
86 Beiträge
 
Delphi 10.2 Tokyo Enterprise
 
#6

AW: MSSQL DB Restore Problem

  Alt 14. Jan 2020, 13:30
der erste Code funktioniert ja.
Nun möchte ich ihn mit den Parametern erweitern, woran ich momentan schreitere.

dbPath2 ist die Pfadangabe vom SQL Server 2017

Code:
 with ADOQ1 do
          begin
            dbPath2 := dbPath +sDBName+'.mdf';
            log := dbPath +sDBName+'_log.ldf';
         
            ProgressBar2.Position := 50;
            SQL.clear;        
            SQL.Text := 'restore database :DBName from '
                    //    +'Disk = :BakPfadName with Replace';
                          +'Disk = :BakPfadName WITH FILE = 1, Replace, MOVE :DBName TO :dbPath2, MOVE :logfile TO :log  ';
            Parameters.ParamByName('BakPfadName').Value := sTemp;
            Parameters.ParamByName('DBName').Value := sDBName;
            Parameters.ParamByName('dbPath2').Value := dbPath2;
            Parameters.ParamByName('logfile').Value := sDBName+'_log';
             Parameters.ParamByName('log').Value := log;
            ExecSQL();
Ich glaube, dass hier der Fehler bzw. die Syntax falsch ist.
Code:
 
SQL.Text := 'restore database :DBName from '                  
            +'Disk = :BakPfadName WITH FILE = 1, Replace, MOVE :DBName TO :dbPath2, MOVE :logfile TO :log  ';
  Mit Zitat antworten Zitat