Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag for France

asked on

error script track sp_configure

Hello,

The error Incorrect syntax near '>'. is returned when I executed
 SELECT @LastUpdateTime = DATEADD (HOUR, @hours, @LastUpdateTime);
 SELECT @LastUpdateTime = DATEADD (MINUTE, @minutes, @LastUpdateTime);
 SELECT @LastUpdateTime = DATEADD (SECOND, @seconds, @LastUpdateTime);
 SELECT @LastUpdateTime = DATEADD (MILLISECOND, @milliseconds, @LastUpdateTime); 

SELECT @LastUpdateTime AS 'sp_configure options last updated'; 

IF EXISTS 
(select @LastUpdateTime > DATEADD(DAY, -1, GETDATE()))

BEGIN 
RAISERROR('Error 1, level 11', 11, 1)
    RETURN
END

Open in new window


How can I resolve?

Thanks

Regards
Avatar of Koen Van Wielink
Koen Van Wielink
Flag of Netherlands image

Not sure what your query is trying to do, but the error is throws because you can't put comparison operators in the select part of the query. They have to be in a where clause.
Try this:

IF EXISTS 
(select 1
where	@LastUpdateTime > DATEADD(DAY, -1, GETDATE()))

Open in new window

Avatar of bibi92

ASKER

Ok, the syntax error is resolved but the raiserrror doesn't work.

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Koen Van Wielink
Koen Van Wielink
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial