|
Posted by
Marcus
on
|
Paschal,
Visual Studio allows you to create a "Database Project". You can find this listed in "Other Projects" on the Add New Project dialog.
You will be prompted to "Add New Reference", so just go ahead and create a reference to your build database.
The project will then present you with 3 folders in the Solutions window. If this is the first time you've used this, you can right click the "Create Scripts" folder and choose Generate Create Script. The usual SQL Server create scripts dialog will be presented and you can choose what is to be created. All the files will be automatically added to the project.
Once all the required scripts have been added, you can then right click and "Create a Command File". This will generate a command batch file run your scripts against the database. The only problem here is that there is a dependency on "osql.exe" which as far as I know (you'll have to check) is not re-distributable... Check the license agreement!
Using the database projects in this way, you can also add all the individual SQL files to source control which makes keeping code and SQL in version sync that much easier.
The project outputs from this project can then be added to your Setup and Deployment project as normal.
You will need however to customise the installer so that it prompts the user to create the database and run the command file. This is easier if you are using a tool such as InstallShield, but with a little digging on the net, you can find samples to show you how this is done.
Marcus
|
|