views:

28

answers:

1

Dear Friend,

How can i Retrive Root Directory in SQL Server using SQL Query???

Thanks.

+1  A: 

The gist of it is this:

Code Snippet

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]

Taken from here

LittleBobbyTables