cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
jchristman
Level 8

Installscript SQL SERVER

I have an installscript project and I have a sql connection that uses the default dialog box, i would like to be able to use installscript to print out into my log file the SQL Server and the datbase that was selected for that dialog.
Labels (1)
0 Kudos
(23) Replies
hidenori
Level 17

You need to write your code that will open your SQL script files and parse SQL batches to be sent to servers if you write an ADO application. There is a sample code available in the SQL Server Database Maintenance section at http://www.installsite.org/pages/en/isp_db.htm.

If you do not want to write that code, you may want to consider using osql Utility or sqlcmd Utility provided by Microsoft to execute your SQL scripts. You can launch the command line utility from your setup using the LaunchAppAndWait() InstallScript function.

Hope that helps.
0 Kudos
jchristman
Level 8

When trying to use LaunchAppAndWait I am trying to run CMD.exe and pass in the sqlcmd string but all I can get is the command prompt window to open.
Example:


LaunchAppAndWait(WINSYSDIR^"cmd.exe","sqlcmd -S myServer -d myDB -E -i mySQLscript.sql", WAIT);


This will open up the command window but does not execute the line.
Is there a way to accomplish this?
0 Kudos
jchristman
Level 8

I figured it out I had to add some more stuff to my svString. I have changed around to work like so.


svString = " /C \"sqlcmd -S mySQLServer -d myDB -E -i \"" + SUPPORTDIR^"mySQLScript.sql" + "\""
LaunchAppAndWait(WINSYSDIR^"cmd.exe",svString,WAIT);

It is very important to get the delimiters correct and add the space infront of the /C you could also use a /K if you want the window to stay open.

I hope the work I have done and that you have helped me with in this thread helps other people. 😉
0 Kudos