cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
bigdavelamb
Level 3

Create database SQL script after installation of SQL Server

Hello

I am doing a silent installation of SQL Server 2008 via prerequisite, the INSTANCE name of the SQL Server installation uses a property that is passed in (the user sets this via a textbox in a dialog).

However once the SQL Server installation is complete I then wish to automatically run a database script (which includes database creation), I am attempting to do this using the SQL Scripts options, but I cannot work out how to get the INSTANCE name property and then use this in my script? Can this be done (I am using a Basic MSI project).

I tried messing about with Advanced tab in scripts the property "Target Server Property Name" and changing this to be the database the user types but I cannot get it to work, can it be done, and I am going about it the right way?

Thank you very much.
David
Labels (1)
0 Kudos
(2) Replies
hidenori
Level 17

If you want to use the information for the target database server on the SQLLogin dialog, you need to set it to the IS_SQLSERVER_SERVER property. Here is a sample Control Event that will set the value of the MYPROP_USERINPUT property to the IS_SQLSERVER_SERVER property:

Event: [MYPROP_USERINPUT]
Argument: [IS_SQLSERVER_SERVER]
Condition: 1

If you want to use the information in your SQL script, you can use the Text Replacement functionality provided in the SQL Script view. Here is a sample Text Replacement entry that will replace %DBNAMEHOLDER% with the value of the MYPROP_USERINPUT property:

Find What: %DBNAMEHOLDER%
Replace With: [MYPROP_USERINPUT]

and your SQL script will look like this:

CREATE DATABASE %DBNAMEHOLDER%

Hope that helps.
0 Kudos
bigdavelamb
Level 3

Thanks very much.

David
0 Kudos