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 3933032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:33:20+00:00 2026-05-19T23:33:20+00:00

I have inherited a nightmarish WTF sproc that inserts 300k rows into a table

  • 0

I have inherited a nightmarish WTF sproc that inserts 300k rows into a table of outbound marketing emails. We want to not queue messages to email addresses that are bouncing. We have a separate table of bouncing emails.

The right way to do this is to modify the sproc to not insert rows for bouncing email.

Nobody wants to touch the nightmarish clusterfuck that is this particular sproc. We are considering adding a delete command to the sproc thusly.

BEGIN TRANSACTION

    --400+ lines of nightmarish WTF T-SQL, string and XML replacement nonsense goes here--
    DELETE FROM EmailQueueItems 
WHERE ToAddress IN 
    (SELECT EmailStatuses.Email FROM EmailStatuses 
        INNER JOIN EmailEventTypes on EmailEventTypes.EmailEventTypeId = EmailStatuses.EmailEventTypeId
        WHERE  EmailEventTypes.CanSendMarketing = 0)
COMMIT TRANSACTION

so…. will this work? Can I delete inserts from a table before the transaction commits?

  • 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-05-19T23:33:20+00:00Added an answer on May 19, 2026 at 11:33 pm

    Yes, you can insert records, and delete same, to a table within the transaction.

    Try this sample for proof of concept:

    declare @foo table (id int)
    begin tran
    
        insert into @foo 
            values (1),(2),(3)
    
        delete @foo where id = 2
    
        select * from @foo --will result in 2 rows: 1 and 3
    
    commit tran
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have inherited a database that has a table (300gb) full of SQL datatype
We have inherited an application (Java-based, running on WebLogic 10.3.5) that makes extensive use
I have inherited a somewhat messy query that I am working on refactoring to
I have inherited an application that logs the results of certain daily commands that
I have inherited a DotNetNuke codebase and have come across areas that have included
I have inherited a piece of Javascript that uses the Google Feed API. It
I have inherited a working VB.NET 2.0 web app that has several User Controls
I have inherited a Websphere Portal project that uses Hibernate 3.0 to connect to
I have inherited a large admin winforms application that shares a 'Common' library of
I have inherited a 20-year-old interactive command-line unix application that is no longer supported

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.