Solved

How to use is equal to in stored proc?

Posted on 2009-04-07
1
201 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
1 Comment
 
LVL 2

Accepted Solution

by:
AlvinLim84 earned 50 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 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