How do I create an installation that automatically generates a SQL Server database?

Generally avoid putting intelligence in the setup package. Here are your options:

  1. 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.


    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

  2. You open your Windows Application and call osql on startup

  3. You open your Windows Application and call SSW SQL Deploy on startup (recommended)


    Call Refresh Samples from Tools menu

Spot an error? Please comment about this article

Keywords: SSW SQL Total Compare  SSW SQL Deploy  SSW SQL Auditor  Hot Tip - SQL Server 2000    

New Search SSW Custom Support