# Replace .SDF database file through .msi upgrade proceed

http://msdn.microsoft.com/en-us/library/windows/desktop/aa371221(v=vs.85).aspx
Since there's no File Version attribute for the SDF database file for the Existing File replacement policy, but sometimes we really need to replace the SDF file(change the init data, or others things makes you need to replace the database file).
Then we just can edit the .MSI file File table to add the File Version number for the .SDF file, then it can use the Existing File replacement policy:

Then we just need to update the version number once we need to replace the .sdf database file for our product.

Then we can configure the Setup project Post-build Event according to this command to update the msi file:

Cscript WiRunSQL.vbs Setup2.msi "UPDATE File SET File.Version='1.0.0.0' WHERE File.FileName = 'DATABA~1.SDF|Database1.sdf'"

https://skydrive.live.com/redir.aspx?cid=bb789f72272d4858&resid=BB789F72272D4858!723&parid=BB789F72272D4858!721

[C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\sysmgmt\msi\scripts\WiRunSQL.vbs]

I have not found any MSDN document mentioned this way to help our work, this is just based on my experiences and test cases, so please consider carefully before use this way in your product deployment.

posted @ 2012-02-06 15:34  Mike Dos Zhang  阅读(233)  评论(0编辑  收藏  举报