我尝试从 Delphi (XE2) 代码创建 SQL Server 数据库快照 (MSSQL EXPRESS 2012 SP #1)。代码执行没有任何问题,但实际上没有创建快照文件
代码示例:
.... LoadStringfromFile(sqlFilename, sqlString);
sqlString := StringReplace(sqlString, 'db_snapshot_name', SnapshotName, []);
sqlString := StringReplace(sqlString, 'physical_file_name', SnapshotFolder, []);
sqlString := StringReplace(sqlString, 'logical_file_name', DatabaseName, []);
sqlString := StringReplace(sqlString, 'source_database_name', DatabaseName, []);
Memo1.Lines.Add(sqlString); // result see below ....
ExecuteSQLQuery(sqlString);
SSStatusBar.SimpleText := ' run sql file done ! ';
end;
procedure TSnapShotForm.ExecuteSQLQuery(const sqlValue: string);
var
aSQLQuery: .....;
begin
///
///
aSQLQuery:=.......Create(self);
aSQLQuery.Active := false;
aSQLQuery.Connection := aConnection;
aSQLQuery.SQL.Add(sqlValue) ;
aSQLQuery.Active := true;
aSQLQuery.Free;
end;
与此文本一起使用的 SQL 语句如下所示
CREATE DATABASE test_ss
ON ( NAME = 'test_evaluation',
FILENAME = 'd:\test_ss')
AS SNAPSHOT OF test_evaluation
有什么好主意吗?