I am creating an NSIS installer and I need to get the version of SQL server the users has installed.
The user will give me the instance name so I can connect to the box. Then I run this sql query select SERVERPROPERTY ('ProductMajorVersion') and get the major version number.
But when I try to do is from NSIS I am not succeeding as it errors when it is executing the query so I do not get the result from the console window.
Below is what I have in my NSIS file:
nsExec::ExecToStack "'sqlcmd -S $SQL_Instance_Name -E -h-1 -Q $\"SET NOCOUNT ON; select SERVERPROPERTY ($\'ProductMajorVersion$\')$\"'"
Pop $0
Pop $1
I have also tried:
ExecCmd::Exec "'sqlcmd -S $SQL_Instance_Name -E -h-1 -Q $\"SET NOCOUNT ON;
select SERVERPROPERTY ($\'ProductMajorVersion$\')$\"'"
Pop $0
Pop $1
But I am just not getting my desired result any advise or suggestions would be appreciated.
Alternatively if there in easier and quicker way to get this information from the Registry then that would be fine as well.
TIA Andy