SQL Server:如何选择安装路径? [英] SQL Server: How to SELECT the installation path?

查看:97
本文介绍了SQL Server:如何选择安装路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一个变量、函数或存储过程可以用来查找 SQL Server 的安装路径:

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

例如:

c:\Program Files\Microsoft SQL Server\MSSQL.7\MSSQL

m:\CustomInstance\MSSQL

<小时>

实际上,我希望选择默认备份路径.但由于我怀疑它是否存在,我将把 \BACKUP 附加到安装路径上,并称其足够接近.


In reality, i'm hoping to SELECT for the default backup path. But since i doubt that exists, i'll just tack \BACKUP onto the install path and call it close enough.

select filename from sysaltfiles
where name = db_name()

Server: Msg 208, Level 16, State 1, Line 1
Invalid object name 'sysaltfiles'.

<小时>

select filename from master.dbo.sysaltfiles
where name = db_name()

filename
---------------- 

(0 row(s) affected)

推荐答案

如何选择安装路径

注意:xp_instance_regread 不会读取您指定的注册表项,而是将该键路径转换为您指定的特定 SQL Server 实例的适当路径.正在运行.换句话说:xp_regreadxp_instance_regread 成功的地方失败.

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.

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 备份目录

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 定位函数

这篇关于SQL Server:如何选择安装路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆