Skip to main content

SQL Server 2005 send email from job

Start Menu – Program Files – Microsoft SQL Server 2005 – Configuration Tools – SQL Server 2005 Surfrace Area Configuration – Surface Area Configuration for Features


Under Database Engine – Database Mail – tick Enable Database Mail stored procedures

In SSMS – Under Management – right click Database Mail – Configure Database Mail


Set up Database Mail by performing the following tasks:
Type Profile name then choose Add


Type Account name, Email address, Display name, Reply e-mail if any, SMTP Server name and port number

Under SQL Server Agent – right click Operators – New Operator



Type Name, tick Enabled and Email name. u can separate by semicolon (;) if u want to send to many recipients

Under SQL Server Agent – right click Jobs – New Job

In General – type Name, Owner, Category if any

In Steps – type Step name, Type, Command. I choose so the backup set will have ‘day month year’ name

DECLARE @filename NVARCHAR(250)
select @Filename = 'D:\DATABASE\MSSQL.1\MSSQL\Backup\DB_BACKUP_' +
CONVERT(NVARCHAR(2), datepart(day,getdate())) +
LEFT(datename(month,getdate()),3) +
CONVERT(NVARCHAR(4), datepart(year,getdate())) + '.bak'
BACKUP DATABASE [DB_BACKUP] TO DISK = @Filename WITH NOFORMAT, NOINIT, NAME = N'DB_BACKUP-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
GO

Create any schedules if any
In Notifications – tick Email and choose Operator that u created earlier. And choose wether to send email when job completes, failed only or success only


U must restart SQL Server Agent to take effect then execute the job u created to see an email coming :D

i attached the 'grapichal' documents here :D

see u

Comments