5 responses

  1. Lee Linares
    2017-08-30

    Thanks for taking the time to post this very helpful article. I have however run into an interesting problem. When capturing the results from xp_instance_regenumvalues I get this error: Msg 213, Level 16, State 7, Procedure xp_instance_regenumvalues, Line 1 [Batch Start Line 26] Column name or number of supplied values does not match table definition.

    Breaking it down I found this to be the problem:

    When I execute this statement:
    ———————————
    EXECUTE master.sys.xp_instance_regenumvalues
    ‘HKEY_LOCAL_MACHINE’,
    ‘Software\Microsoft\MSSQLSERVER\MSSQLSERVER’;

    The entry returned for the NumErrorLogs value has TWO Value fields:
    ———————————————————-
    Value Value Data
    NumErrorLogs NULL 20

    But when I execute this statement:
    ———————————-
    EXECUTE master.sys.xp_instance_regread
    ‘HKEY_LOCAL_MACHINE’,
    ‘Software\Microsoft\MSSQLSERVER\MSSQLServer’,
    ‘NumErrorLogs’;

    It returns this:
    ——————–
    Value Data
    NumErrorLogs 20

    I checked this on several different SQL servers (SQL 2012 and 2014) and got the same results.

    Any ideas?

    Thanks.

    Lee

    Reply

    • Wayne Sheffield
      2017-08-31

      Hmm, I can replicate this, and this is indeed interesting.
      In looking through the registry at this key, all of the keys are being returned except for uptime_time_utc, and this is a reg_binary data type. My guess would be that the reg_binary key is causing this issue.

      Reply

  2. P.C.
    2019-01-29

    This seems to be a bug in SQL Server SP sys.xp_instance_regenumvalues. Once you have different number of columns on output you cannot insert it into a table. Binary values are skipped w/o problems.

    Reply

Leave a Reply to let me know how you liked this post

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back to top
mobile desktop