williamkremer
Programmer
- Oct 27, 2005
- 61
I think that I'm close here, but I'm getting errors, and what I am attempting to do is to pull that ch.accountno into the @accountno variable so that the update in the contact1 occurs where that accountno (unique) is.
****************************************
CREATE TRIGGER TrgLastCont ON Ch
FOR Update AS
declare @accountno varchar (20)
declare @ondate varchar (11)
if exists (SELECT top 1 cast (ch.ondate as varchar(11)), ch.accountno
from ch where (ch.ondate <> '' or ch.ondate is not null)
and ch.resultcode = 'CT' and ch.ondate = getdate()
order by ch.ondate desc)
Begin
set @accountno = ch.accountno
update Contact1 set Key3 = @ondate
where contact1.accountno = @accountno
end
***********************
The error reads: "Line 13: The column prefix 'ch' does not match with a table name or alias name used in the query." I think I need some learnin' here. Thanks in advance!
Best regards,
Bill
****************************************
CREATE TRIGGER TrgLastCont ON Ch
FOR Update AS
declare @accountno varchar (20)
declare @ondate varchar (11)
if exists (SELECT top 1 cast (ch.ondate as varchar(11)), ch.accountno
from ch where (ch.ondate <> '' or ch.ondate is not null)
and ch.resultcode = 'CT' and ch.ondate = getdate()
order by ch.ondate desc)
Begin
set @accountno = ch.accountno
update Contact1 set Key3 = @ondate
where contact1.accountno = @accountno
end
***********************
The error reads: "Line 13: The column prefix 'ch' does not match with a table name or alias name used in the query." I think I need some learnin' here. Thanks in advance!
Best regards,
Bill