
I want to retrieve the maximum number of error开发者_C百科 log file value using SQL Query.
From running SQL Server Profiler and tracing the calls this is what SSMS does.
declare @NumErrorLogs int
exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', 
                            N'Software\Microsoft\MSSQLServer\MSSQLServer',
                            N'NumErrorLogs', 
                            @NumErrorLogs OUTPUT
SELECT @NumErrorLogs
The number of Sql error log files setting is stored in the windows registry at "[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS_ADV\MSSQLServer]\NumErrorLogs"
It can be retrieved using the following sql (from sql profiler).
 use master
    declare @HkeyLocal nvarchar(18)
    declare @MSSqlServerRegPath nvarchar(31)
    declare @InstanceRegPath sysname
    select @HkeyLocal=N'HKEY_LOCAL_MACHINE'
    select @MSSqlServerRegPath=N'SOFTWARE\Microsoft\MSSQLServer'
    select @InstanceRegPath=@MSSqlServerRegPath + N'\MSSQLServer'
    declare @NumErrorLogs int
    exec master.dbo.xp_instance_regread @HkeyLocal, @InstanceRegPath, N'NumErrorLogs', @NumErrorLogs OUTPUT
    SELECT
    ISNULL(@NumErrorLogs, -1) AS [NumberOfLogFiles]
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论