Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

How to use is equal to in stored proc?

Hi

I need to select 2 values from 2 fields of 2 tables and compare them.

It has error:
Msg 102, Level 15, State 1, Procedure SP_Transaction, Line 13
Incorrect syntax near '='.
Msg 102, Level 15, State 1, Procedure SP_Transaction, Line 14
Incorrect syntax near ')'.


If ((select sum(amount) as amount from subtransaction where transactionsid=43) = 
(select amount from transactions where id=43) and 
(select sum(payoutamount) as payoutamount from subtransaction where transactionsid=47 =
(select countervalue from transactions where id=47))
 
update transactions set status = 3 where id =43
update subtransaction set status = 3 where id =47

Open in new window

0
techques
Asked:
techques
1 Solution
 
AlvinLim84Commented:
Try this:
If ((select sum(amount) as amount from subtransaction where transactionsid=43) = 
(select amount from transactions where id=43) and 
(select sum(payoutamount) as payoutamount from subtransaction where transactionsid=47) =
(select countervalue from transactions where id=47))
 
update transactions set status = 3 where id =43
update subtransaction set status = 3 where id =47

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now