database-mail

Scripting setup of database mail

筅森魡賤 提交于 2019-12-18 04:39:12
问题 I've used the SQL Server 2008 GUI to set up database mail profiles & accounts on my test server, and I'd now like to duplicate those to our production database. Is there a way to generate a script to do this? 回答1: AFAIK, there isn't a way to necessarily script this from SSMS but you can create a transportable script in TSQL once and reuse it on all the servers. Here is a good example to get you started with this: USE [master] GO sp_configure 'show advanced options',1 GO RECONFIGURE WITH

How to give access to SQL Server database mail procedures for a Login in a different database?

早过忘川 提交于 2019-12-06 22:34:03
问题 I'd like to know how to set up permissions within SQL Server to allow my application Login/Role to be able to send email using msdb.dbo.sp_send_dbmail . I have a database MyDb, a user MyUser who is a member of role AppRole . I have a stored procedure myProc that calls msdb.dbo.sp_send_dbmail . If I execute myProc while logged in as sa it all works fine, but if I execute while logged in as MyUser I get an error: Msg 229, Level 14, State 5, Procedure sp_send_dbmail, Line 1 The EXECUTE