I am having a problem executing a SQL Server script as part of my install. I have tried using three different methods:
- 1. Embed the sql scripts into the install in the Project Details -> SQL Scripts section
2. Launch osql from the command line to execute the script
3. Launch osql from a VBScript to execute the script
The second method works, but briefly displays an undesired command prompt window during the install.
The third method fails at the moment, but I am trying to track down the problem. Here is the VBScript I am using:
Code: Select all
Function runSqlServerScript(database, script)
Const ERROR_SUCCESS = 0
Set WshShell = CreateObject("WScript.Shell")
runSqlServerScript = WshShell.Run("osql -S .\SQLEXPRESS -E -d " + database + " -b -i " + script, 1, true)
Exit Function
End Function
- a. Are my assumptions about the first method correct or should I investigate this further? (I assume this is the preferred method for SQL Scripts)
b. How can I pass an installed SQL script file to the VBScript function above?
-kevin