Consider:
CREATE PROCEDURE LowerCityDiscounts @city VARCHAR(45), @decrease DECIMAL(10,2) AS
BEGIN
BEGIN TRANSACTION;
UPDATE Customers SET discnt = discnt - @decrease
WHERE Customers.city = @city;
UPDATE Customers SET discnt = 0
WHERE Customers.city = @city AND discnt < 0
COMMIT;
END;
I tried to call this procedure with:
CALL LowerCityDiscounts 'Cleveland', 5;
but this only produces
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'Cleveland'.
Yet, if I change things to
EXEC LowerCityDiscounts 'Cleveland', 5;
everything works fine. This despite that the documentation stating that call is the right syntax.
Why does EXEC work when CALL does not?
Yup..
CALLis an construct/syntax usable from an ODBC driver, as your documentation indicates.There’s no reference in the T-SQL documentation to
CALL, onlyEXEC.It doesn’t work because it’s not T-SQL.