SQL Server Sending mails twice

  • Hi ,

    I have a job which has 4 steps :

    Step 1:executes DTS package

    Step 2:sends mail to everyone using this code

    EXEC msdb.dbo.sp_send_dbmail

    @profile_name = 'sqlserver'

    ,@recipients = 'MailAddress

    ,@importance = 'High'

    ,@subject = 'Forecast'

    ,@body = 'Please see attachment - *** OLF ***'

    ,@file_attachments = 'FolderName'

    Step 3: again executes another DTS Package

    Step 4: again sends mail to everyone like using step 2 code but with different subject.

    after the final completion the SQL Agent job sends mail using Notifications.

    the problem we are seeing is :

    we are receiving mails 2 times with step 2 attached file and 2 times with step 4 attached file and in between these two mails we are receiving SQL Agent Mail.

    I am supposed to receive Mail from SQL Agent at last why i am i receiving in between step 2 and step 4 mails and why am i receiving 2 mails after step 2 execution and 2 mails after step 4 execution..

    Can anyone please tell me what is going wrong?

  • Do you possibly have two schedules that are running at the same time?

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • No,we didnot schedule it 2 times.

  • How close in time do the duplicate jobs run ?

    You could have just 1 schedule, but it is set as recurring twice in a small timeframe.

    For instance, "Run every 5 minutes starting at 1:00 and ending at 1:09."

    It would run at 1:00 and 1:05

    Not very likely to be set up this way, but it is possible.

  • Can you right click on the job a create the scripts?

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

Viewing 5 posts - 1 through 4 (of 4 total)

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