Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Triggers

Status
Not open for further replies.

sogibear

Programmer
Jul 4, 2002
45
GB
Hello,
I've got two tables :
tblTimetable : ClientID, Mon, Tue, Wed, Thu, Fri, Sat, Sun
tblTimetable_Timeslot : ClientID, TslotID

e.g:
tblTimetable :
ClientID Mon Tue Wed Thu Fri Sat Sun
404 10 2 20 0 0 0 0

tblTimetable_Timeslot :
ClientID TslotID
404 10
404 2
404 20

I'm trying to write a trigger on tblTimetable so that when Mon, Tue, Wed etc is changed to "0", the trigger looks up the appropriate record in tblTimetable_Timeslot and deletes it ! Thats it really, have never been good with Triggers

Any help would be greatly appreciated
Thanks
:)
 
Code:
create trigger on tblTimetable for update
as
begin
delete tblTimetable_Timeslot
from tblTimetable_Timeslot , inserted i, deleted d
where tblTimetable_Timeslot.clientId = d.clientId
  and tblTimetable_Timeslot.clientId = i.clientid
  and (     (TslotId = d.mon and i.mon = 0)
         or (TslotId = d.tue and i.tue = 0)
         or (TslotId = d.wed and i.wed = 0)
         or (TslotId = d.thu and i.thu = 0)
         or (TslotId = d.fri and i.fri = 0)
         or (TslotId = d.sat and i.sat = 0)
         or (TslotId = d.sun and i.sun = 0))
end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top