Database mail error

  • SQL Server 2012 . I have set up a profile and account.

    use msdb
    GO

    EXEC sp_send_dbmail

    @profile_name='adminprofile@abc.com',

    @recipients='user1@abc.com',

    @subject='Test message',

    @body='This is the test body'

    I ran the code and I am the sysadmin in the server . I get the following error in the event viewer

    The update to the database failed. Reason: The EXECUTE permission was denied on the object 'sysmail_logmailevent_sp', database 'msdb', schema 'dbo'.

  • That would suggest you aren't a sysadmin, if you're getting write permissions. What does the below return:
    SELECT sysadmin
    FROM master.sys.syslogins
    where name = SYSTEM_USER;

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Thom A - Tuesday, April 25, 2017 9:45 AM

    That would suggest you aren't a sysadmin, if you're getting write permissions. What does the below return:
    SELECT sysadmin
    FROM master.sys.syslogins
    where name = SYSTEM_USER;

    Returns 1

  • Is the service account for SQL Server Agent in the sysadmins role?
    Try running the following and see if there is a local windows group in sysadmins role for the service account:
    EXEC sp_helpsrvrolemember 'sysadmin'

    Sue

  • Sue_H - Tuesday, April 25, 2017 10:56 AM

    Is the service account for SQL Server Agent in the sysadmins role?
    Try running the following and see if there is a local windows group in sysadmins role for the service account:
    EXEC sp_helpsrvrolemember 'sysadmin'

    Sue

    Yes it is.
    NT SERVICE\SQLSERVERAGENT

  • I also added NT SERVICE\MSSQLSERVER to the sysadmin role and it worked , I am not getting the previous permission to execute error now.

  • Guras - Tuesday, April 25, 2017 11:10 AM

    I also added NT SERVICE\MSSQLSERVER to the sysadmin role and it worked , I am not getting the previous permission to execute error now.

    But I do not understand the solution 🙁

  • Guras - Tuesday, April 25, 2017 11:14 AM

    Guras - Tuesday, April 25, 2017 11:10 AM

    I also added NT SERVICE\MSSQLSERVER to the sysadmin role and it worked , I am not getting the previous permission to execute error now.

    But I do not understand the solution 🙁

    Most likely, you made changes outside of Configuration Manager to end up with those issues. The groups, roles, permissions in SQL Server as well as the operating system are all managed when using Configuration Manager. Even using the Services app is a bad idea.
    You could check the groups on the server and make sure the correct accounts are in both of the groups.
    How the permissions and different accounts work is documented here:
    Configure Windows Service Accounts and Permissions

    Sue

Viewing 8 posts - 1 through 7 (of 7 total)

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