SQL Error Log

摘要:SQL Error Log

Reference :
 http://sharedderrick.blogspot.hk/2010/04/sql-servererror-log-file.html

 

- 每次重啟SQL server 或執行stored procedure sp_cycle_errorlog,即會建立新的錯誤記錄檔。

- 查詢錯誤記錄檔存放的path
  SELECT ServerProperty('ErrorLogFileName')

- 查詢錯誤記錄檔日期 / size
  exec sp_enumerrorlogs

- 檢視錯誤記錄檔
  exec sp_readerrorlog

- 預設保留前6份錯誤記錄檔,加當下錯誤記錄檔共7份。xp_instance_regwrite 可調整欲保留的份數:
USE [master]
GO

EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', 
                                              N'Software\Microsoft\MSSQLServer\MSSQLServer',
                                              N'NumErrorLogs', 
                                              REG_DWORD,
                                              10
GO  

 

- 修改副檔名的數字,會影響記錄檔的排序: