i am attempting to restore a backup database file using WiX, and the database is created but none of the tables and data are restored. it seems as though it is only creating the database and doing nothing else. not sure if this is WiX related or has something to do with MSSQL usage. here is the 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>
i have also tried "WITH RECOVERY" and using escape sequence around the square brackets:
<sql:SqlString Id="attach_db" ExecuteOnInstall ="yes" ExecuteOnReinstall="no" ExecuteOnUninstall="no" ContinueOnError="yes" Sequence="1" SQL="RESTORE DATABASE blankaaa FROM DISK = '[\[]blankaaaBAK[\]]' WITH RECOVERY;" />
the proper way to do this seems wretchedly unclear in the documentation.
rather than trying to refer to the wix name of the database file, i used the following:
SQL="RESTORE DATABASE blankaaa FROM DISK = '[INSTALLFOLDER]javaaaanew\blankaaa.bak' WITH RECOVERY"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With