Generally, avoid putting intelligence in the setup package. Here are your options:
- You can use Wise and call osql
We use a product called Wise Install Master to generate our installations. In that, we use a script command called 'Execute' and run the 'osql.exe' to run a .sql script.
E.g.
Execute %MAINDIR%\osql.exe /S %SERVER% /E /d Master /i ""%MAINDIR%\Samples\CreateNorthwindSample.sql"" /o ""%MAINDIR%\Log_CreateNorthwindSample.txt"" /n
Note:Other installation products could also use this functionality such as InstallShield.
The sample code is the contents of a .sql file that will create a sample database called 'NorthwindSample'.
Sample file to Create the Database (rename .txt to .sql)
PLEASE NOTE: we have renamed the .sql file as .txt in order to view it in the browser. To get it working it needs to be renamed back to .sql - You open your Windows Application and call osql on startup
- You open your Windows Application and call SSW SQL Deploy on startup (recommended)