我知道有一个变量,函数或存储过程可用于查找SQL Server安装到的路径:
例如:
c:\Program Files\Microsoft SQL Server\MSSQL.7\MSSQL
要么
m:\CustomInstance\MSSQL
实际上,我希望SELECT为默认备份路径.但由于我怀疑存在,我只是将\ BACKUP添加到安装路径并将其调得足够接近.
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)
Ian Boyd.. 12
注意:xp_instance_regread不会读取您指定的注册表项,而是将该密钥路径转换为您正在运行的特定SQL Server实例的相应路径.换句话说:xp_regread在xp_instance_regread成功的地方失败.
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
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位置函数
注意:xp_instance_regread不会读取您指定的注册表项,而是将该密钥路径转换为您正在运行的特定SQL Server实例的相应路径.换句话说:xp_regread在xp_instance_regread成功的地方失败.
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
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位置函数