Stacie
asked on
Store procedure - Syntax - Why not running properly-- ???
I have the following the code from a book but I'm getting the following error. Not Sure why. I run this into SQL Server Management Studio and create a new store procedure... What I'm missing>
Code:
Error
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'IF'.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'in_customer_id'.
Msg 155, Level 15, State 2, Line 7
'NUMERIC' is not a recognized CURSOR option.
Msg 195, Level 15, State 10, Line 14
'CONCAT' is not a recognized built-in function name.
Code:
DROP PROCEDURE IF EXISTS customer_sales
$$
CREATE PROCEDURE customer_sales
(in_customer_id INT)
READS SQL DATA
BEGIN
DECLARE total_sales NUMERIC(8,2);
SELECT SUM(NumberOfEmployees)
INTO total_sales
FROM dbo.Customer
WHERE CustomerNumber=in_customer_id;
SELECT CONCAT('Total sales for ',in_customer_id,' is ',total_sales);
END;
$$
Error
Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword 'IF'.
Msg 102, Level 15, State 1, Line 4
Incorrect syntax near 'in_customer_id'.
Msg 155, Level 15, State 2, Line 7
'NUMERIC' is not a recognized CURSOR option.
Msg 195, Level 15, State 10, Line 14
'CONCAT' is not a recognized built-in function name.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window