Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8846409
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T11:58:36+00:00 2026-06-14T11:58:36+00:00

I have several stored procedures structured like the following: USE [WHouse] GO SET ANSI_NULLS

  • 0

I have several stored procedures structured like the following:

USE [WHouse]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[pr_Alert_Dly]
AS
    IF (SELECT LastRunDate FROM WHouse.dbo.AlertRunDates WHERE NameDescription = 'X' ) < (SELECT CONVERT(DATE, GETDATE()))
    BEGIN
       --================
       --need to comment the following out if trying to re-run
       UPDATE x 
       SET  x.LastRunDate = CONVERT(DATE,GETDATE())
       FROM WHouse.dbo.AlertRunDates x
       WHERE [NameDescription] = 'X' 
       --================

       --===============
       --DO A LOAD OF STUFF IN HERE 
       --INCLUDING USING DB_SENDMAIL TO EMAIL 20 PEOPLE
       --===============

    END

My colleague has set up a reporting system (using procedures / SSIS) that loops every 10 minutes and as long as a stored procedure completes without an error then it is marked as complete in a control table.

What I don’t understand is even if the above throws an error why would it ever repeat the section between BEGIN / END more than once in the same batch ?

If it is not defensive enough how do defend against my colleagues system causing the same emails to get distributed every 10 minutes?!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T11:58:38+00:00Added an answer on June 14, 2026 at 11:58 am

    Ultimately scrapped the pattern in the OP and have used the suggestions put forward by Aaron in the comments of the OP i.e created a EmailQueue table and set up a background process that loops every 5mins (via the Agent). This process scans the EmailQueue table for any new records and sends out emails if required.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several stored procedures that all use the same set of parameters. Is
I have several stored procedures which return a strongly typed result set. I've learned
I have several stored procedures that use an outer apply. The query inside the
I have several stored procedures in my database. For example a delete stored procedure
I have a rather huge query that is needed in several stored procedures, and
Say I have a stored procedure consisting of several separate SELECT, INSERT, UPDATE and
I have several images stored in content://media/external/images/media. I would like to display by using
so I have written several stored procedures that act on individual rows of data
We have several stored procedures marked as articles for replication in our SQL2000 database.
I have a SQL stored procedure that I need to execute several times with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.