Archive: How to Detect SQL Server 2005 and SQL Express from NSIS


How to Detect SQL Server 2005 and SQL Express from NSIS
Dear Friends,

From my NSIS installer I'll restore a database of SQL Server 2005. But prior to this act I want to confirm whether the user's system is having SQL Server 2005 or SQL Server 2005 Express Edition (SSE). Please note that I don't need instance names etc. info., just want to know whether SQL 2005 or SSE is there or not.

Please keep in mind that, the user may have other versions of SQL Server installed in his system like MSDE, SQL 2000.


For MSDE/MSSQL I use:
ReadRegStr $R0 HKLM \
"SOFTWARE\Microsoft\MSSQLServer\Setup" SQLPath

For my this issue, I'm trying with the following but someone informed me that it didn't detected his sql express.
Please give better and correct solution then this:

;for sql server 2005
ReadRegStr $R1 HKLM \
"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" MSSQLSERVER
;for sql express:
ReadRegStr $R2 HKLM \
"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" SQLEXPRESS


Regards,
Swapan
ps:As usual its need quick response as my installer is just waiting for this check to be bundled in it.


if you are still working on your installer,

microsoft kb321185 could be helping you.

run the following statement with osqlor your preferred way of running DB-Scripts from the commandline:

SELECT SERVERPROPERTY ('productlevel')

depending on what is installed, you should get something like
"RTM" or "SQL Server 2005" so you can go further with this return val.

I haven't tested it yet, because i currently hav no SQL2005 here, but the statement works under SQL2000 too.

have a look at the link for further informations about the ServerProps.

Greetz


if MS SQL Server run, You can ask him about sql server version,
but You can not start it, if You don't know, which version client has.


Thanks for the reply. Will check and let you know in this thread. Actually was looking for some registry level solution.

Regards & Thanks,