比个例子你参考一下
-备份 BACKUP DATABESE 数据库名 TO DISK='X:/XXX/XXXXXX' WITH INIT
--恢复 RESTORE DATABASE 数据库名 FROM DISK='X:/XXX/XXXXX' WITH REPLACE
backup database user_info to --直接用这条语句备份数据库文件
disk ='C:/Program Files/Microsoft SQL Server/MSSQL/backup/a.mdf' with init
restore database user_info from --直接使用这条语句恢复数据库文件
disk ='C:/Program Files/Microsoft SQL Server/MSSQL/backup/a.mdf'
DELPHI里程序备份
procedure TForm1.Button1Click(Sender: TObject);
begin
if fileexists('C:/Program Files/Microsoft SQL Server/MSSQL/backup/c.mdf') then
begin
adoquery1.Close;
adoconnection1.Connected :=false;
deletefile('C:/Program Files/Microsoft SQL Server/MSSQL/backup/c.mdf');
end;
adoquery1.close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add('backup database user_info to disk ='+quotedstr('C:/Program Files/Microsoft SQL Server/MSSQL/backup/c.mdf'));
adoquery1.ExecSQL;
end;