-
Writing a Trigger - Help
Hi Guys,
I am trying to create my first trigger.
I have a table called qdDutyEvents with fields starttime, and OpDay =(Operational day (Monday, Tuesday, Wednesday etc)
I need to check that when a new start time is entered into my table that it doesn’t already exists on the same operational day.
In other words if OPDay = Monday then I can only have ONE starttime of 08:00
I do not know is how write the trigger to monitor all the records in the table, actually how to start at the beginning of the table and run through the records and check if my Opday is Monday(for example) and starttime 08: 00 if it already exists it must send an error and NOT update the table
Anybody that could help me PLEASE, Please, Please
TopCat
-
-
Hi rmiao
Thanks for replying, but I figured it out
I created a temp table and as I dump new records in, I compare the startdates and as soon as I have more than one I just delete them
WHERE int2_OpDays & @ MyOpDays > 0
IF EXISTS (SELECT * FROM #Tmp)
BEGIN
RAISERROR ('Duplicate Start timeinserted into qdDutyevents', 16,1)
ROLLBACK TRANSACTION
END
the duplicates.
So till I start sweating with th next problem......
you'll here from me again
Have a marvellous day
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|