UDF Woes

  • Greetings All,

    I am trying to write a UDF to read a registry value from the server, specifically:

    EXEC master.dbo.xp_regread 'HKEY_LOCAL_MACHINE',

    'SYSTEM\CurrentControlSet\Control\TimeZoneInformation',

    'DisableAutoDaylightTimeSet', @autoDST OUTPUT

    This key is 'attached' to the "Automatically adjust clock for daylight saving changes" checkbox in the Date and Time Properties dialog.

    The issue:  The key is present when the checkbox is UNchecked; when checked, the key is deleted and the above will return an error which cannot be 'handled' in the UDF (i.e. high volume usage will eventually cause issues).

    I've tried various 'legal', 'illegal' and just plain ugly methods of getting around this but am having no luck.  This needs to be a UDF because it will be called from another UDF.

    Any assistance is appreciated!

    TIA,

    Art

     

     

  • This may help, but then again, it may not:

    http://qa.sqlservercentral.com/forums/shwmessage.aspx?forumid=8&messageid=103789

    John Rowan

    ======================================================
    ======================================================
    Forum Etiquette: How to post data/code on a forum to get the best help[/url] - by Jeff Moden

  • Thanx John,

    I thought I might have gotten the answer via that link with xp_regenumvalues but ran into the same sort of problem - no temp tables in UDF's so no INSERT..EXEC so no usable data.

    Who'd a thunk MS would create/delete the key depending upon the state of the checkbox??

    Still trying but with much less fervor...

    Art

  • Can you not write your own code to read the registry and make it into a DLL?  One that would not return an error, or at least a less severe error, if an entry did not exist in the registry?

    There's samples available that reads a node from a registry - I've used some in some VB programs.

  • I could but I'm not thrilled about adding an xp to substitute for an existing xp.  I considered that option but have decided to tolerate the error for the time being.

    Thanx for the suggestions!

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply