Click here to Skip to main content
15,906,567 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
CREATE PROCEDURE Transfer
@orderValue int,
@custFName nvarchar(20),
@custLName nvarchar(20)
AS
UPDATE [Money]
FROM CustomerBankInfo
INNER JOIN Customer
ON CustomerBankInfo.CustomerID = Customer.CustomerID
SET [Money] = [Money] - @orderValue;
WHERE Customer.FirstName = @custFName AND Customer.LastName = @custLName



"INCORRECT SYNTAX NEAR '='"

SET [Money] = [Money] - @orderValue;


What am I doing wrong? Could someone help me out please.
Posted

1 solution

You cannot join two tables in update statement. You can use subqueries instead. Try the ff. codes:

SQL
UPDATE CustomerBankInfo
SET Money = (money - @ordervalue)
WHERE CustomerBankInfo.CustomerID = (SELECT CustomerID
                                     FROM Customer
                                     WHERE Firstname = @custFName
                                     AND LastName = @custName)
 
Share this answer
 
Comments
WurmInfinity 12-Dec-11 17:58pm    
You Sir, are a God among men. Thanks a lot :)
[no name] 12-Dec-11 20:07pm    
you are welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900