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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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:
The other option would be to leverage SMO, either through .NET or powershell to generate the scripts. The SMO reference for this would be:
SqlMail Class
UPDATE:
Here is how easy it turned out to be to script this with Powershell and SMO: