How can I use WiX properties in a sql file execute

2019-08-04 12:41发布

I have a WiX install project that I am rewriting based on our previous installers from Wise. In Wise, you can add files for it to execute (ours used sql script files) and it had a replace tab that specified certain text in the file to be replaced with either with static text or a Wise property.

I am wondering if this is possible in WiX?

Example:

use [SQLDBNAME]
SELECT *
FROM Employee

Where WiX would read the file and replace the [SQLDBNAME] with the value set in WiX's properties table?

标签: wix
1条回答
我欲成王,谁敢阻挡
2楼-- · 2019-08-04 13:15

The Property replacement works for SqlString element, where you define the SQL string literally as a value of the attribute. However, it doesn't work for SqlScript element, where you put the entire SQL script file to Binary. It all depends on how complex is your SQL queries.

When using SqlString, don't forget that SQL uses [ and ] to escape its own reserved words. So you should escape the MSI properties like this in that case: [\[] and [\]].

Hope this helps.

查看更多
登录 后发表回答