cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Madhu_Mitra
Level 3

How to get the default SQL Server Name

Hello,
I am using SQL Server 2008 Express Edition. How can I get the default SQL Server name from Install shield? I am not allowed to use the SQLServerSelect dialog of installshield. I tried getting the SQL Server name with the following code

szKey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SQL Server\\Instance Names\\SQL";

szName = "MSSQLSERVER";
RegDBGetKeyValueEx(szKey, szName, nvType, svValue, nvSize)

The variable "svValue" is always blank.

Please suggest me how do I get the default SQL Server Name.

Cheers
Madhu
Labels (1)
0 Kudos
(3) Replies
dheeraj
Level 3

0 Kudos
hidenori
Level 17

If the default SQL Server is a 64-bit version, make sure that you set the REGDB_OPTIONS system variable appropriately (something like REGDB_OPTIONS = REGDB_OPTIONS | REGDB_OPTION_WOW64_64KEY) before your registry read.
0 Kudos
rcurro
Level 3

I used ServiceExistsService("MSSQLSERVER") and it works without a problem. That way I didn't have to deal with the 64-bit and 32 bit registry.

Robert
0 Kudos