cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
hrushikesh1600
Level 4

Installscript execute SQL script and return values

Hi all,

I have an Installscript MSI project that requires me to connect to a (possibly) remote DB engine and figure out the version number before proceeding. I am using the SqlServerSelectLogin2(...) dialog to get the credentials from the user and then using SQLRTTestConnection2(...) to test the authenticity. Once the credentials provided by the user pass, I need to verify that the SQL version is 2008 R2 or above (and not express). If the DB engine was local, I would use the registry route to figure out the version number and that works fine. What I am stumped with is how to detect the version for a remote DB engine. I know I need to run the "SELECT @@VERSION" query using the SQL scripts view but I am at a loss on how to pass data back to the Installscript to take the next steps. Upon searching briefly, I have seen that this is a problem that has come up before and is unsolved (http://community.flexerasoftware.com/showthread.php?163524-How-to-determine-SQL-Server-Version-of-a-remote-machine).

I also tried using the hint provided in the given link to use SQLCMD.exe to execute commands but that poses two problems - the utility is a part of the client tools so the end user is not guaranteed to have it, and writing the results to file will result in a file being generated respective to the server machine, not the client. Because of this, i have come to the conclusion that the only feasible way is to go via the SQL scripts view. My questions are:

1) How to execute a specific SQL script file using installscript (there are multiple files under one component and I would need to execute just one to figure out the version)
2) How to pass data back to the Installscript? Can the properties somehow be used?

Thanks!
Rishi
Labels (1)
0 Kudos
(13) Replies