williamkremer
Programmer
- Oct 27, 2005
- 61
Hi all, I never did get this trigger to update the Contact1 table when 'CT' value is entered into Conthist. Simply put, nothing at all happens! I gave up on it for a while, but now I'd like to revisit the thing. Thanks for any insights ..
**************************
IF EXISTS (SELECT name FROM sysobjects
WHERE name = 'TrgLastCont' AND type = 'TR')
DROP TRIGGER TrgLastCont
GO
CREATE TRIGGER TrgLastCont ON Conthist
FOR Update AS
declare @accountno varchar (20)
declare @ondate varchar (11)
declare @resultcode varchar(3)
declare @DateNow datetime
select @DateNow = convert(varchar,getdate(),110)
SELECT top 1 @ondate = cast (conthist.ondate as varchar(11)),
@accountno = conthist.accountno, @resultcode = conthist.resultcode
from conthist where (conthist.ondate <> '' or conthist.ondate is not null)
and conthist.resultcode = 'CT' and conthist.ondate >= @DateNow
and conthist.ondate < dateadd(d,1, @DateNow)
order by conthist.ondate desc
if @resultcode = 'CT'
Begin
update Contact1 set Key3 = @ondate
where contact1.accountno = @accountno
end
"You cannot hold a torch to another man's path without brightening your own"
Best regards,
Bill
**************************
IF EXISTS (SELECT name FROM sysobjects
WHERE name = 'TrgLastCont' AND type = 'TR')
DROP TRIGGER TrgLastCont
GO
CREATE TRIGGER TrgLastCont ON Conthist
FOR Update AS
declare @accountno varchar (20)
declare @ondate varchar (11)
declare @resultcode varchar(3)
declare @DateNow datetime
select @DateNow = convert(varchar,getdate(),110)
SELECT top 1 @ondate = cast (conthist.ondate as varchar(11)),
@accountno = conthist.accountno, @resultcode = conthist.resultcode
from conthist where (conthist.ondate <> '' or conthist.ondate is not null)
and conthist.resultcode = 'CT' and conthist.ondate >= @DateNow
and conthist.ondate < dateadd(d,1, @DateNow)
order by conthist.ondate desc
if @resultcode = 'CT'
Begin
update Contact1 set Key3 = @ondate
where contact1.accountno = @accountno
end
"You cannot hold a torch to another man's path without brightening your own"
Best regards,
Bill