SQL Server Installation Path

The installation path for SQL Server 2000 can be determined using the undocumented sp_msget_setup_paths Stored Procedure.  This procedure performs a Reg Read for the particular SQL Server instance to determine the install path from HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSSQLServer\Setup for the default instance or HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\instance\Setup for a named instance.  Below is an example of how to use sp_msget_setup_paths to determine the installation path.

 

DECLARE @sqlpath SYSNAME
DECLARE @datapath SYSNAME

EXEC master.dbo.sp_msget_setup_paths @sqlpath OUT, @datapath OUT

SELECT @sqlpath, @datapath