From: http://nsis.sourceforge.net/How_to_tell_what_version_of_SQLServer_is_installed
1. The Code is as follows: Function StrTokExch $ R1Exch 1 Exch $ R0Push $ R2Push $ R3Push $ R4Push $ R5; R0 fullstring; R1 tokens; R2 len of fullstring; R3 len of tokens; r4 char from string; R5 testchar StrLen $ R2 $ R0IntOp $ R2 $ R2 + 1 loop1: intOp $ R2 $ R2-1 IntCmp $ R2 0 exit StrCpy $ R4 $ R0 1-$ R2 StrLen $ R3 $ R1IntOp $ R3 $ R3 + 1 loop2: intOp $ R3 $ R3-1 IntCmp $ R3 0 loop1 StrCpy $ R5 $ R1 1-$ R3 StrCmp $ R4 $ R5 FoundGoto loop2Goto lo Op1 exit:; Not found !!! StrCpy $ R1 "" StrCpy $ R0 "" Goto Cleanup Found: strLen $ R3 $ R0IntOp $ R3 $ R3-$ R2StrCpy $ R1 $ R0 $ R3 IntOp $ R2 $ R2-1 IntOp $ R3 $ R3 + 1 StrCpy $ R0 $ R0 $ R2 $ r3 Cleanup: pop $ R5Pop $ R4Pop $ R3Pop $ R2Exch $ R0Exch 1 Exch $ R1 FunctionEnd; ------------------------------; CheckMinSQLVersion; Written by Matthew Kershaw (matthew.kershaw@us.didata.com );; for this function the min SQL version must be SQL2kSP2 ...; Typically the SQLServer version is located in; HKLM \ SOFTWARE \ Microsoft \ MSSQLServer \ CurrentVersion; but for SPs, the new version is located in; HKLM \ SOFTWARE \ Microsoft \ MSSQLServer \ CurrentVersion \ CSDVersion .; for SP2, the value is 8.00.534. if the CSDVersion key does not exist,; no SP has been installed. function CheckMinSQLVersion ClearErrors ReadRegStr $0 HKLM "SOFTWARE \ Microsoft \ MSSQLServer \ CurrentVersion" "CurrentVersion" IfErrors SQLServerNotFound SQLServerFound: readRegStr $4 HKLM "SOFTWARE \ Microsoft \ MSSQLServer \ CurrentVersion" "CSDVersion" IfErrors SPNotFound SPFound:; Check the first digit of the version; must be 8 StrCpy $0 $4 StrCpy $1 $0 1 StrCmp $1 "8" SQLServer2000Found SQLServerVersionErrorGoto ExitC HeckMinSQLVersion SQLServer2000Found: Push $0 Push ". "Call StrTok; For an example string of" 8.00.194 "," 8 "and" 00.194 "now on stackPop $2 Push ". "Call StrTok;" 00 "and" 194 "now on stackPop $ 2Pop $3 IntCmp $3 534 0 SQLServerVersionError 0 Push 1 Goto ExitCheckMinSQLVersion SQLServerVersionError: messageBox MB_ OK | MB_ICONEXCLAMATION "The minimum SQLServer version required for this product is v8.00.534 (SQLServer 2000, SP2). It is detected that the current version is $0. The installer is aborted. "Push 0 Goto ExitCheckMinSQLVersion SQLServerNotFound: MessageBox MB_ OK | MB_ICONEXCLAMATION" the installer fails to detect Microsoft SQLServer, which must be installed. The installer is aborted. "Push 0 Goto ExitCheckMinSQLVersion SPNotFound: MessageBox MB_ OK | MB_ICONEXCLAMATION" MicrosfotSQLServer v $0 is installed. SQLServer 2000 SP2 (or later) must be installed. The installer is aborted. "Push 0 Goto ExitCheckMinSQLVersion: FunctionEnd 2. Call CheckMinSQLVersionPop $0 IntCmp $0 1 + 2 Abort