views:

246

answers:

2

Hi, my default SQL Server 2005 log directory is full on C drive. In order to prevent this issue happening in future, I plan to move the default log directory to some other place. Could you please tell me how I can move the error log default directory?

I browsed the web, there is solution for SQL Server 7 and 2000 but not 2005. Please kindly help.

Regards Qing

A: 

When you use SSMS and click on generate script it creates T-SQL like this

  USE [msdb]
    GO
    EXEC dbo.sp_set_sqlagent_properties @errorlog_file=N'C:MSSQL\Log\SQLAGENT.OUT'
    GO

I just verified that it works, just make sure that the folder exist otherwise agent won't start

you probably also need to run this first, probably the proc above is disabled (by default)

EXEC master.dbo.sp_configure 'show advanced options', 1

RECONFIGURE

EXEC master.dbo.sp_configure 'Agent XPs', 1

RECONFIGURE
SQLMenace
+3  A: 

Go to server properties and look for start up parameters. Probably right-click in object explorer, properties, advanced (I can't check in SSMS now).

The path is the "e" switch. Change and restart.

It can't be set in documented SQL commands :-)

Basically, it's in the registry as one of the parameters to the sqlservr.exe binary when run as a windows service

gbn
I'm not sure if there is a tool interface for this. The registry key depends on the SQL version and isntance name, eg. SQL 2008 Default instance is: `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQLServer\Parameters`
Remus Rusanu
Btw, the parameter is not passed to the binary from the Service Control Manager. SCM passes only the instance name via `-sINSTANCENAME` and the SQL binary then reads the startup parameters from its own registry key for the instance name passed in from SCM sstart up params.
Remus Rusanu
I seem to recall using SQL 2000 EM to view it, but it's been some time obviously. As for startup, I usually think more about when running command-line startup to run single user mode etc
gbn
Found it, is the SQL Server Configuration Manager tool that allows you to set the startup parameters w/o having to manually edit the registry.
Remus Rusanu