Unanswered: [RESOLVED] What's wrong with my TRIGGER?
On my VB form, user terminates an employee by entering a date on a textbox control (EndDate). When saving the edited record, I get a run time error "- 2147217871 TIMEOUT EXPIRED".
When I remove the trigger, record is saved with no problems. What's wrong with the trigger? It used to work before the last time I can remember.
CREATE TRIGGER tr_TERMINATE ON dbo.Employee
DECLARE @EndDate smalldatetime
DECLARE @EmployeeID int
SELECT @EndDate = EndDate FROM inserted
SELECT @EmployeeID = EmployeeID FROM inserted
IF @EndDate is not null
UPDATE SubStore SET EmployeeID = 10000 WHERE EmployeeID=@EmployeeID
UPDATE Store SET EmployeeID = 10000, [Permanent] = 0 WHERE EmployeeID=@EmployeeID
UPDATE WOTemp SET EmployeeID=10000 WHERE EmployeeID=@EmployeeID
DELETE EmpBuddy WHERE BuddyID=@EmployeeID
After trying to figure out almost half a day what's wrong with this trigger (it used to work before!!), I see that it was crapping out on the first UPDATE statement. I tried each UPDATE statement and it was not working too.
I even used SQL Server Query Analizer and it was also not doing the update commands.
Heck, I rebooted my PC and it worked like a charm afterwards. I can only shake my head right now. Ohhh well, at least my problem is gone.