sql-server – WiX:数据库还原不会还原表和记录

我正在尝试使用WiX还原备份数据库文件,并且已创建数据库但未恢复任何表和数据.它似乎只是创建数据库而不做任何其他事情.不确定这是否与WiX有关或与MSsql使用有关.这是WiX XML
<Component Id="sql_backup_restore" Guid="8C95F258-7AB7-4A3A-A0CD-438FC61D45CC">
        <CreateFolder Directory="javaaaanew_dir"/>
        <sql:sqlDatabase Id="aaanew3_db" Server="[MSsqlSERVER]" Database="master" ConfirmOverwrite="yes" ContinueOnError="yes" DropOnReinstall="no" DropOnInstall="no" DropOnUninstall="no" CreateOnInstall="yes" CreateOnReinstall="no" CreateOnUninstall="no">
          <!-- restore blankaaa database -->
          <sql:sqlString Id="attach_db" ExecuteOnInstall ="yes" ExecuteOnReinstall="no" ExecuteOnUninstall="no" ContinueOnError="yes" Sequence="1" sql="RESTORE DATABASE blankaaa FROM disK = '[blankaaaBAK]' WITH RECOVERY;" />
          <!-- rename blankaaa to aaanew3 -->
          <sql:sqlString Id="alter_db_name" ExecuteOnInstall ="yes" ExecuteOnReinstall="no" ExecuteOnUninstall="no" ContinueOnError="yes" Sequence="2" sql="USE master;GO;ALTER DATABASE blankaaa Modify Name = 'aaanew3' GO;" /> <!-- should fail here if preexisting database? -->
          <!-- change aaanew3 dbowner to 'sa' -->
          <sql:sqlString Id="alter_db_owner" ExecuteOnInstall ="yes" ExecuteOnReinstall="no" ExecuteOnUninstall="no" ContinueOnError="yes" Sequence="3" sql="ALTER AUTHORIZATION ON DATABASE::aaanew3 TO sa;" />
          <!-- add user 'sa' to database security? -->
          <sql:sqlString Id="alter_db_sa" ExecuteOnInstall ="yes" ExecuteOnReinstall="no" ExecuteOnUninstall="no" ContinueOnError="yes" Sequence="4" sql="USE [aaanew3];GO;CREATE USER [sa] FOR LOGIN [sa];GO;" />
          <!-- add user mapping for 'sa' on aaanew3 with schema 'dbo' -->
          <sql:sqlString Id="alter_db_schema" ExecuteOnInstall ="yes" ExecuteOnReinstall="no" ExecuteOnUninstall="no" ContinueOnError="yes" Sequence="5" sql="USE [aaanew3];GO;ALTER USER [sa] WITH DEFAULT_SCHEMA=[dbo];GO;" />
        </sql:sqlDatabase>
      </Component>

我也试过“WITH RECOVERY”并在方括号周围使用转义序列:

<sql:sqlString Id="attach_db" ExecuteOnInstall ="yes" ExecuteOnReinstall="no" ExecuteOnUninstall="no" ContinueOnError="yes" Sequence="1" sql="RESTORE DATABASE blankaaa FROM disK = '[\[]blankaaaBAK[\]]' WITH RECOVERY;" />

在文档中看起来不太清楚这种做法的正确方法.

解决方法

而不是尝试引用数据库文件的wix名称,我使用以下内容
sql="RESTORE DATABASE blankaaa FROM disK = '[INSTALLFOLDER]javaaaanew\blankaaa.bak' WITH RECOVERY"

相关文章

SELECT a.*,b.dp_name,c.pa_name,fm_name=(CASE WHEN a.fm_n...
if not exists(select name from syscolumns where name=&am...
select a.*,pano=a.pa_no,b.pa_name,f.dp_name,e.fw_state_n...
要在 SQL Server 2019 中设置定时自动重启,可以使用 Window...
您收到的错误消息表明数据库 &#39;EastRiver&#39; 的...
首先我需要查询出需要使用SQL Server Profiler跟踪的数据库标...