Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to use is equal to in stored proc?

Posted on 2009-04-07
1
Medium Priority
?
208 Views
Last Modified: 2012-05-06
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
Comment
Question by:techques
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
AlvinLim84 earned 150 total points
ID: 24087488
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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I am showing a way to read/import the excel data in table using SQL server 2005... Suppose there is an Excel file "Book1" at location "C:\temp" with column "First Name" and "Last Name". Now to import this Excel data into the table, we will use…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question