SQL Server: How to SELECT the installation path?

前端 未结 4 1293
滥情空心
滥情空心 2020-12-15 12:44

i know there is a variable, function, or stored procedure that you can use to find the path that SQL Server is installed to:

e.g.:

c:\\Program Files\         


        
4条回答
  •  独厮守ぢ
    2020-12-15 13:10

    Execute the following to inspect the registry in order to find the appropriate key.

    Declare @Path as varchar(100);
    Set @Path = NULL
    
    Exec master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\Microsoft SQL Server\70\Tools\ClientSetup', 'SQLPath', @Path OUTPUT
    Select @Path as [Sql Server 7.0 path] 
    
    Set @Path = NULL
    Exec master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\Microsoft SQL Server\80\Tools\ClientSetup', 'SQLPath', @Path OUTPUT
    Select @Path as [Sql Server 2000 path] 
    
    Set @Path = NULL
    Exec master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\Microsoft SQL Server\90\Tools\ClientSetup', 'SQLPath', @Path OUTPUT
    Select @Path as [Sql Server 2005 path]
    
    Set @Path = NULL
    Exec master..xp_regread 'HKEY_LOCAL_MACHINE', 'SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\ClientSetup', 'SQLPath', @Path OUTPUT
    Select @Path as [Sql Server KATMAI path]
    

提交回复
热议问题