Sql-server – why i am getting The EXECUTE permission was denied on the object ‘sp_send_dbmail’, database ‘msdb’, schema ‘dbo’

sql server

When I am only trying to create a table my "DBA" gave reader, writer, "ddladmin" to the database and I am getting this error when trying to create a basic table:

The EXECUTE permission was denied on the object 'sp_send_dbmail', database 'msdb', schema 'dbo'

Can somebody please let me know the answer.

Best Answer

There are two possibilities here:

  1. Your table create script includes an attempt to send an email
  2. Your DBA has placed a DDL trigger on the database to send an email notification when objects are created.

In the first instance, confirm that there are no attempted email sends from your script.

For the second the DBA might not have set the permissions correctly on the trigger itself, and so it is attempting to send an email using your credentials. Work with the DBA to either grant you permission on msdb..sp_send_dbmail so that emails will flow, or to fix up the trigger.