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

前端之家收集整理的这篇文章主要介绍了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"
原文链接:https://www.f2er.com/mssql/77239.html

猜你在找的MsSQL相关文章