Sql Root Directory and error log location

Hi, Can anyone help me in finding the SQL server Root directory and error log location using a sql script for multi-instances, cluster and non cluster servers.
more ▼

asked Jun 23, 2011 at 07:22 PM in Default

srivivek gravatar image

519 41 42 43

(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

SQL script will not be the best candidate for this.

I suggest you take a look for a PowerShell script. As the installation directory is stored in the registry and the log location is part of the startup parameters of the SQL Server service.

Anyway you can take a look here for the inspiration of the t-sql solution to retrieve installation directory: [How to find the SQL Server install directory from tsql][1]

[1]: http://social.msdn.microsoft.com/forums/en-US/transactsql/thread/04cc91e9-7dc3-462f-a2b7-23f00eaa863f/
more ▼

answered Jun 24, 2011 at 01:36 AM

Pavel Pawlowski gravatar image

Pavel Pawlowski
22.3k 9 11 21

(comments are locked)
10|1200 characters needed characters left

I was playing around with some stuff on a cluster and using PowerShell you can actually use this to get your information (if you have PowerShell running on the servers of course). You will also need SMO loaded, which this is already there if SSMS is installed on the host machine.

[System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.Management.SMO') |
$s = New-Object 'Microsoft.SqlServer.Management.Smo.Server' instance_name
$s.Information.RootDirectory | Write-Host -foreground Red
$s.Information.ErrorLogPath | Write-Host -foreground Red
$s.Information.MasterDBPath | Write-Host -foreground Red
$s.Information.MasterDBLogPath | Write-Host -foreground Red
more ▼

answered Jun 30, 2011 at 12:30 PM

Shawn_Melton gravatar image

5.4k 20 21 29

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Jun 23, 2011 at 07:22 PM

Seen: 1949 times

Last Updated: Jun 23, 2011 at 07:22 PM