I am trying to rollback a transaction with the following statement:
BEGIN CATCH
IF SUM(Point FROM Players) != 4000
ROLLBACK TRANSACTION [Tran1]
But I get an error saying:
'SUM' is not a recognized built-in function name
How do I write the code in the correct way?
The context use you SUM
in is wrong. SUM
takes a scalar expression, it doesn't use the {expression} FROM {object}
syntax.
Use a subquery:
IF (SELECT SUM(Point) FROM dbo.Players) <> 4000
...