where can I query the 'Enable Mail Profile' value from the Agent properties

  • Hi All,

    I'm looking to query (via SQL) the 'Enable Mail Profile' value from the Agent properties, but I've been unable to find the appropriate view.

    http://technet.microsoft.com/en-us/library/ms181367.aspx lists the SQL Server Agent Tables, but I haven't been able to find anything enlightening.

    Thanks in advance

    Simon.

  • You can use following:

    EXEC msdb.dbo.sp_set_sqlagent_properties @databasemail_profile=N''

    HTH

    ---------------------------------------------------
    "Thare are only 10 types of people in the world:
    Those who understand binary, and those who don't."

  • I believe this is stored in the registry. If you view the source of EXEC msdb.dbo.sp_set_sqlagent_properties all the properties are stored in the registry.

  • Thanks Guys,

    Interesting but not really what I'm after.

    To put it another way.

    My Problem - I found one of my servers had the Agent Mail Profile unchecked, and it wasn't sending emails about failed jobs.

    I'd like to programatically check all my database servers to find any others which may be wrong.

    Any other ideas ?

    Thanks

    Simon.

  • OK, You lead me to a solution.

    declare @val nvarchar(4000)

    exec master.dbo.xp_instance_regread

    N'HKEY_LOCAL_MACHINE',

    N'Software\Microsoft\MSSQLServer\SQLServerAgent',

    N'DatabaseMailProfile',

    @val output

    select @val

    I did a file compare of that registry key (exported) and the only diff between having the checkbox checked or not is the 'DatabaseMailProfile'

    "DatabaseMailProfile"="DBA Profile"

    vs.

    "DatabaseMailProfile"=""

    Thanks heaps

    Simon.

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

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