Howzit,
so im working on this trigger and its pissing me off as i cannot find the correct way to do it:
3 tables involved here:
TblSIID
tblService
tblApplication
Very simple: If the status is updated to 10 for the 1 record (tblSIID) - tblService must be updated.
the relations are tblSiid (contact number) -> tblApplication (contactno)
tblApplication (ApplicationID) -> tblService (ApplicationID).
My Code is as such:
CREATE TRIGGER fUpdate
ON tblSIID
AFTER UPDATE
AS
IF (SELECT TOP 1 Status FROM deleted) = '10'
BEGIN
SET NOCOUNT ON
UPDATE tblService set ssID = '2061'
WHERE ((SELECT TOP 1 ContactNo From Deleted) in
(SELECT TOP 1 ContactNo from tblApplication a
inner join tblService b on a.Applicationid = b.Applicationid))
end
Problem is. If i remove the top1 in bold, it updates the entire service table. If i leave the bold in, it doesnt update.
Any ideas?
so im working on this trigger and its pissing me off as i cannot find the correct way to do it:
3 tables involved here:
TblSIID
tblService
tblApplication
Very simple: If the status is updated to 10 for the 1 record (tblSIID) - tblService must be updated.
the relations are tblSiid (contact number) -> tblApplication (contactno)
tblApplication (ApplicationID) -> tblService (ApplicationID).
My Code is as such:
CREATE TRIGGER fUpdate
ON tblSIID
AFTER UPDATE
AS
IF (SELECT TOP 1 Status FROM deleted) = '10'
BEGIN
SET NOCOUNT ON
UPDATE tblService set ssID = '2061'
WHERE ((SELECT TOP 1 ContactNo From Deleted) in
(SELECT TOP 1 ContactNo from tblApplication a
inner join tblService b on a.Applicationid = b.Applicationid))
end
Problem is. If i remove the top1 in bold, it updates the entire service table. If i leave the bold in, it doesnt update.
Any ideas?