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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:43:37+00:00 2026-06-09T00:43:37+00:00

I have the following trigger: BEGIN DECLARE @email varchar(200) DECLARE @jobcode int DECLARE @status

  • 0

I have the following trigger:

BEGIN
DECLARE @email varchar(200)
DECLARE @jobcode int
DECLARE @status char(1)

DECLARE @emaild varchar(200)
DECLARE @jobcoded int
DECLARE @statusd char(1)

SET @statusd = NULL

SELECT @status = z.status, @email = p.EMail, @jobcode = z.jobID
    FROM zipoutfiles z
    INNER JOIN inserted AS i ON z.jobID = i.jobID
    INNER JOIN PS_LoginUser AS p ON z.UserID = p.UserID

SELECT @statusd = z.status, @emaild = p.EMail, @jobcoded = z.jobID
    FROM zipoutfiles z
    INNER JOIN deleted AS d ON z.jobID = d.jobID
    INNER JOIN PS_LoginUser AS p ON z.UserID = p.UserID
    WHERE d.jobID = @jobcode


IF ((@status = 'D' AND @statusd = 'R') OR (@status = 'D' AND @statusd = 'E'))
BEGIN
    EXEC SendMail @email, @jobcode
END
END

I want to be able to run SendMail when status goes from E to D or R to D, but not D to D (if it gets updated again) and also when it gets inserted as D. What am I doing wrong here:

  • 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-09T00:43:38+00:00Added an answer on June 9, 2026 at 12:43 am

    Not sure what your table schemas are, but this may get you all of the appropriate emails:

    select p.EMail as Email, z.JobId as JobCode
      from ZipOutFiles as ZOF inner join
        inserted as i on i.JobId = ZOF.JobId inner join
        PS_LoginUser as PLU on PLU.UserId = ZOF.UserId left outer join
        deleted as d on d.JobId = ZOF.JobId
        where
          ( d.Status = 'E' and i.Status = 'D' ) or -- E -> D.
          ( d.Status = 'R' and i.Status = 'D' ) or -- R -> D.
          ( d.Status is NULL and i.Status = 'D' ) -- Inserted D.
    

    I’ve assumed that you aren’t really updating JobId. If so, how do you match the before and after rows?

    Also assumed is that Status cannot be NULL. If so, the last condition needs to be modified to properly detect no corresponding row was found in the deleted table.

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

Sidebar

Related Questions

I have the following trigger: CREATE TRIGGER Users_Delete ON Users AFTER DELETE AS BEGIN
I have the following function that is supposed to trigger anytime one of the
I have the following code being run if an iphone/ipad/ipod is detected: $('.tooltip-trigger').tooltip({offset: [20,
I have the following table: CREATE TABLE FE_USER ( userid int identity (321,4) CONSTRAINT
I have the following trigger but need ti find the identity of the row
I have an application, it is creating an ICS similar to the following: BEGIN:VCALENDAR
I have created the following trigger for insert in the deleted user table the
I have following trigger written for my application which gives me this error Msg
I have two tables with the following column names. users ui | email |
I have the following trigger on a table that redirects data and includes data

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.