Archive
set SQL error log retention period through T-SQL
we all may need to tweak the SQL error log retention period on a single instance or list of SQL server VIA CMS (central management server)
below 2 commands are quite useful for achieving the same
READ the current setting of sql error log retention
/* USE [master] GO EXEC xp_instance_regread N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’NumErrorLogs’ GO */
you may receive below error on few server .. you may want to go ahead with the update command and come back to see the results of xp_instance_regread
possible error message for some server ..
RegQueryValueEx() returned error 2, ‘The system cannot find the file specified.’ servername(username): Msg 22001, Level 1, State 1
set the LOG retention sql error to 20 days
/* USE [master] GO EXEC xp_instance_regwrite N’HKEY_LOCAL_MACHINE’, N’Software\Microsoft\MSSQLServer\MSSQLServer’, N’NumErrorLogs’, REG_DWORD, 20 GO */
above command will set the retention to 20 days and you may rerun EXEC xp_instance_regread to confirm the same setting
CHECK previous POST
Categories
- Cluster (3)
- Database Structure (1)
- DBCC (1)
- Ebook (1)
- execution plan (1)
- General (26)
- INDEXES (19)
- installation (4)
- Installations (4)
- linked Server (2)
- LOA (4)
- memory (1)
- Powershell (8)
- replication (1)
- security (1)
- service pack (2)
- SQL Agent (1)
- T-sql (9)
- Trace flag (1)
- VM (2)
- whitepaper (1)
Disclaimer
This is a personal weblog. The opinions or ideas shared/expressed here are my own and not of my employer. For accuracy ( and to make sure it applies to the version you are concerned ) and official references refer to MSDN, Microsoft TechNet, Books Online. I or my employer do not endorse any of the RDBMS tools / applications / books / concepts mentioned here on my blog. I have documented my personal experiences on this blog.
