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
Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection.
problem:
a working replication setup suddenly started failing with below error ..nothing was changed from configuration aspect of
subscriber .. but the distributor could not connect to the subscriber .. moreover .. the connection to subscriber instance (VIA windows
authentication ) could not browse through properties ETC .. (SQL agent ETC)
error :
Error messages:
The process could not connect to Subscriber ‘subscriber_instance’. (Source: MSSQL_REPL, Error number: MSSQL_REPL20084) Get help: http://help/MSSQL_REPL20084 Login failed for user ‘(null)’. Reason: Not associated with a trusted SQL Server connection. (Source: MSSQLServer, Error number: 18452) Get help: http://help/18452
Solution:
1> login failed for user ‘NULL‘ is basically solved by switching the instance authentication mode to mixed from windows
(in my case it was already so)
2> in the eventvwr .. few kerberos warning and errors were logged in (which looked every cryptic)
3> instead of troubleshooting those .. i decided to bounce the SQL instance .. to see whether it clears the error
for above scenario .. it worked fine .. and NULL user errors were no longer appearing ,replication was working fine ..
other Scenario :
4> you may to change authentication mode to mixed ..
hope this helpful to you 🙂
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)
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 | |||||
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.
