x
login about faq Site discussion (meta-askssc)

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 '11 at 07:22 PM in Default

srivivek gravatar image

srivivek
519 30 39 42

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

2 answers: sort oldest

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

more ▼

answered Jun 24 '11 at 01:36 AM

Pavel Pawlowski gravatar image

Pavel Pawlowski
20.3k 5 10 20

(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') |
out-null
$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 '11 at 12:30 PM

Shawn_Melton gravatar image

Shawn_Melton
4.7k 13 17 27

(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.

Follow this question

By Email:

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

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x599
x50
x11
x2
x1

asked: Jun 23 '11 at 07:22 PM

Seen: 1049 times

Last Updated: Jun 23 '11 at 07:22 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.