Here’s my code that results in error :
SELECT @maxNo = TOP 1 CONVERT(INT,(SUBSTRING(noorder,7,4)))
FROM orders ORDER BY noorder DESC;
It returns:
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword
‘TOP’.
EDIT :
found the answer, i should code like this :
select top 1 @maxNo = CONVERT(int, (SUBSTRING(noorder, 7, 4)))
from orders
order by noorder desc;
thanks to @RedFilter
1 Answer