How to get the installation path of SQL Server

xiaoxiao2021-03-06  41

method 1:

Declare @Path Varchar (200)

EXEC MASTER.DBO.XP_REGREAD

'HKEY_LOCAL_MACHINE',

'Software / Microsoft / MSSQLSERVER / SETUP',

'Sqlpath', @ path output

Set @Path = @PATH '/ DATA /'

Print @PATH

Method 2:

Declare @Path Varchar (200)

SELECT @Path = filename from master.dbo.sysfiles

Set @Path = Ltrim (Reverse (@PATH))

Set @Path = Reverse (Substring (@ Path, Charindex ('/', @ Path), Len (@PATH)))

Print @PATH

转载请注明原文地址:https://www.9cbs.com/read-73091.html

New Post(0)