以下是备份和恢复的两个存储过程,调用就行。
备份
CREATE PROCEDURE sdDb_Backup
@DatabaseName varchar(40),
@FileName varchar(80),
@UserCode varchar(18)
AS
backup database @DatabaseName To DISK=@Filename WITH INIT
if @@Error=0
begin
update sdBackup Set BackupDate=getdate(),
BackupUser=@UserCode
where BackupFile=@FileName
if @@RowCount<1
Insert into sdBackup (BackupDate,BackupFile,BackupUser)
values(Getdate(),@FileName,@UserCode)
end
GO
恢复
CREATE PROCEDURE sdDB_Restore
@DatabaseName varchar(40),
@FileName varchar(80)
AS
Restore Database @DatabaseName From DISK=@FileName
GO
如果是SQL的话,TADOQuery->CommandType=cmdText;
如果是SP的话,TADOQuery->CommandType=cmdStoredProc;