This very simple trigger :
CREATE TRIGGER Booking_Duration ON Booking FOR INSERT, UPDATE AS
SET DaysStay = (SELECT DATEDIFF(dd, FromDate, ToDate))
Fails with this error:
Server: Msg 170, Level 15, State 1, Procedure Booking_Duration, Line 2
Line 2: Incorrect syntax near '='.
I can't see what's wrong with it, but whatever it is it must be subtle, as both DaysStay and the return value of DATEDIFF() are INT.
Can anyone shed some light on this for me please.
CREATE TRIGGER Booking_Duration ON Booking FOR INSERT, UPDATE AS
SET DaysStay = (SELECT DATEDIFF(dd, FromDate, ToDate))
Fails with this error:
Server: Msg 170, Level 15, State 1, Procedure Booking_Duration, Line 2
Line 2: Incorrect syntax near '='.
I can't see what's wrong with it, but whatever it is it must be subtle, as both DaysStay and the return value of DATEDIFF() are INT.
Can anyone shed some light on this for me please.