I need to run a sequence of sql scripts in multiple databases and possibly multiple SQL server instances.
How do I achieve this using the advanced Installer. ?
This can be done by creating multiple connections in the SQL Scripts page. Each connection will have its own SQL scripts and you can order the connections the way you need (the order of execution is set by the order in the "SQL Scripts" page).
If you encounter problems while configuring the SQL connections and scripts you can check out the SQL Script tutorial or post on this thread.
How do I pass the different database names. I can get the database names from the server. But I will need to save these in different properties to be able to pass them uniquely for each connection
If you are referring to getting the names of the databases from the server and using them in your project then this is not supported by Advanced Installer. However, this can be done through a custom action.
If this is not what you are referring to, please give me more details.
If you are referring to getting the names of the databases from the server and using them in your project then this is not supported by Advanced Installer. However, this can be done through a custom action.
Yes. I would like to do exactly that. I want to get the list of databases from the server. Then allow the user to identlify wich database to run the script against. Then run the scripts for those specific databases only.
How would I achive this using custom action ?
do you mean that I would be using vb script or osql script or sqlcmd script to run all my scripts ?
In order to do this you can create a custom action which connects to the server, gets the name of the databases and places them in a combo box. After the user selects a database you can use the property of the combo box in the connection you create in the "SQL Scripts" page.
That was very helpful. I incorporated the code to select from multiple instances.
To populate the combo box with database names, I found this script and modified it. It compiled fine. I am new to vbscript and I am unable to figure out why the combo is not getting the values.
Can you please help again ?
following is my script. In the AI run log it is returning value 0.
' Now were are connected, get the list of databases
szoDataBase = "SQLDMO.Database"
set oDataBase = CreateObject(szoDataBase)
nResult = MsiDatabaseOpenView(hDatabase, "SELECT * FROM ComboBox WHERE Property='DBCOMBO_PROP'", hView)
nResult = MsiViewExecute(hView,NULL)
For nCount = 1 to oSQLServer.Databases.Count
set oDataBase = oSQLServer.Databases(nCount)
if ( oDataBase.SystemObject = FALSE ) then
order = order + 1
hRec = MsiCreateRecord(4)
nResult = MsiRecordSetString(hRec, 1, "DBCOMBO_PROP") ' Column1: Property tied to the entry
nResult = MsiRecordSetInteger(hRec, 2, order) ' Column2: Display order of the item
nResult = MsiRecordSetString(hRec, 3, oDataBase.Name) ' Column3: Value to set property to
nResult = MsiRecordSetString(hRec, 4, oDataBase.Name) ' Column4: Display text for item
nResult = MsiViewModify(hView, MSIMODIFY_INSERT_TEMPORARY, hRec)
nResult = MsiCloseHandle(hRec)
end if
Next
nResult = MsiViewClose (hView)
set oSQLServer = NOTHING
set oDataBase = NOTHING
End Function
--------------------------------------------------------