Click here to Skip to main content
14,696,871 members
Home » Discussions » Database
   

Database

 
AnswerRe: Splitting large amounts of data in a table Pin
Mycroft Holmes2-Apr-20 12:10
professionalMycroft Holmes2-Apr-20 12:10 
AnswerRe: Splitting large amounts of data in a table Pin
Gerry Schmitz2-Apr-20 19:29
mveGerry Schmitz2-Apr-20 19:29 
AnswerRe: Splitting large amounts of data in a table Pin
Victor Nijegorodov3-Apr-20 0:43
MemberVictor Nijegorodov3-Apr-20 0:43 
QuestionQuestion Regarding SQL Parameter Query Pin
Michele Smith31-Mar-20 10:14
MemberMichele Smith31-Mar-20 10:14 
AnswerRe: Question Regarding SQL Parameter Query Pin
ZurdoDev31-Mar-20 10:49
mveZurdoDev31-Mar-20 10:49 
AnswerRe: Question Regarding SQL Parameter Query Pin
Victor Nijegorodov1-Apr-20 2:35
MemberVictor Nijegorodov1-Apr-20 2:35 
AnswerRe: Question Regarding SQL Parameter Query Pin
Richard Deeming1-Apr-20 3:32
mveRichard Deeming1-Apr-20 3:32 
QuestionTrigger keeps inserting duplicates Pin
greatwhite131-Mar-20 8:48
Membergreatwhite131-Mar-20 8:48 
I cannot figure out why my trigger keeps inserting duplicates. Do anyone see what might might be causing it.

/****** Object:  Trigger [dbo].[update_ee_so_email]    Script Date: 3/31/2020 10:34:21 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO


ALTER TRIGGER [dbo].[update_ee_so_email]
   ON  [dbo].[import_new_soemailsubmission]

   AFTER INSERT , UPDATE, Delete
AS

BEGIN

Declare @new_agentId as uniqueidentifier --varchar(10)
Declare @new_email as varchar(50)
Declare @agentid as varchar(10)

Select  @agentid = SO.new_agentId, @new_email = new_email
FROM inserted SE join import_new_serviceorganization SO ON SE.new_agentId = SO.ID

 join app_users a on a.user_name = 'SO-' + SO.new_agentid

IF @agentid is not null
Begin

INSERT INTO EE_SO_MAILING_LISTS ([PARTNER], EMAIL_ADDRESS,STATEMENT_FLAG, REFRESH_DATE)
Values(@agentid, @new_email, 'N', GetDate())


END

Else if exists (Select * from deleted)
Begin

Select  @new_agentId = new_agentId, @new_email = new_email
        FROM deleted

     Select @agentid =new_agentId From import_new_serviceorganization Where id  = @new_agentId



      Delete from EE_SO_MAILING_LISTS where PARTNER = @agentid and EMAIL_ADDRESS  = @new_email
End


END

AnswerRe: Trigger keeps inserting duplicates Pin
ZurdoDev31-Mar-20 10:51
mveZurdoDev31-Mar-20 10:51 
GeneralRe: Trigger keeps inserting duplicates Pin
greatwhite131-Mar-20 14:51
Membergreatwhite131-Mar-20 14:51 
GeneralRe: Trigger keeps inserting duplicates Pin
ZurdoDev31-Mar-20 16:44
mveZurdoDev31-Mar-20 16:44 
AnswerRe: Trigger keeps inserting duplicates Pin
Richard Deeming1-Apr-20 1:44
mveRichard Deeming1-Apr-20 1:44 
RantRe: Trigger keeps inserting duplicates Pin
Mycroft Holmes1-Apr-20 13:45
professionalMycroft Holmes1-Apr-20 13:45 
QuestionHow to calculate the daily and weekly averages using sql server or alternate sql softwares Pin
Barath835730-Mar-20 2:57
MemberBarath835730-Mar-20 2:57 
RantRe: How to calculate the daily and weekly averages using sql server or alternate sql softwares Pin
ZurdoDev30-Mar-20 3:12
mveZurdoDev30-Mar-20 3:12 
AnswerRe: How to calculate the daily and weekly averages using sql server or alternate sql softwares Pin
ZurdoDev31-Mar-20 10:52
mveZurdoDev31-Mar-20 10:52 
AnswerRe: How to calculate the daily and weekly averages using sql server or alternate sql softwares Pin
Mycroft Holmes31-Mar-20 13:50
professionalMycroft Holmes31-Mar-20 13:50 
QuestionCreate a new Primary Key on survey table Pin
learning_new25-Feb-20 13:01
Memberlearning_new25-Feb-20 13:01 
AnswerRe: Create a new Primary Key on survey table Pin
Nathan Minier28-Feb-20 7:38
professionalNathan Minier28-Feb-20 7:38 
AnswerRe: Create a new Primary Key on survey table Pin
Eddy Vluggen28-Feb-20 10:48
professionalEddy Vluggen28-Feb-20 10:48 
AnswerRe: Create a new Primary Key on survey table Pin
David Mujica2-Mar-20 4:56
MemberDavid Mujica2-Mar-20 4:56 
GeneralRe: Create a new Primary Key on survey table Pin
learning_new3-Mar-20 5:28
Memberlearning_new3-Mar-20 5:28 
QuestionIndexing question Pin
Super Lloyd5-Feb-20 14:35
MemberSuper Lloyd5-Feb-20 14:35 
AnswerRe: Indexing question Pin
Eddy Vluggen5-Feb-20 16:09
professionalEddy Vluggen5-Feb-20 16:09 
GeneralRe: Indexing question Pin
Super Lloyd5-Feb-20 18:38
MemberSuper Lloyd5-Feb-20 18:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.