SQL Server: How to SELECT the installation path?

前端 未结 4 1340
滥情空心
滥情空心 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:14

    How to select the installation path

    Note: xp_instance_regread doesn't read the registry key you specify, but instead converts that key path into the appropriate path for the specific SQL Server instance you're running on. In other words: xp_regread fails where xp_instance_regread succeeds.

    SQL Server Installation Directory

    declare @rc int, @dir nvarchar(4000) 
    
    exec @rc = master.dbo.xp_instance_regread
          N'HKEY_LOCAL_MACHINE',
          N'Software\Microsoft\MSSQLServer\Setup',
          N'SQLPath', 
          @dir output, 'no_output'
    select @dir AS InstallationDirectory
    

    SQL Server Backup Directory

    declare @rc int, @dir nvarchar(4000) 
    
    exec @rc = master.dbo.xp_instance_regread
          N'HKEY_LOCAL_MACHINE',
          N'Software\Microsoft\MSSQLServer\MSSQLServer',
          N'BackupDirectory', 
          @dir output, 'no_output'
    select @dir AS BackupDirectory
    

    SQL Server 2000 Location Functions

提交回复
热议问题