What is wrong with this following query? I can't find the error. Can anyone help me with this issue?
IF (NOT EXISTS(SELECT *
FROM chennai_metro_data
WHERE TIME1 ='09:00' AND DATE1 ='1-23-2017'))
BEGIN
INSERT INTO chennai_metro_data
VALUES (2021700002,'1-23-2017','09:00',1,0,555555)
END
ELSE
BEGIN
UPDATE chennai_metro_data
SET CUMFLOW = 555555
WHERE TIME1 = '09:00' AND DATE1 = '1-23-2017'
END
I'm getting this error:
Msg 206, Level 16, State 2, Line 1
Operand type clash: int is incompatible with date
INSERT..... that helps avoid a lot of problems !