Solved

SQL store procedure problem

Posted on 2009-05-15
2
162 Views
Last Modified: 2012-05-07
I have the following stored prodedure below.

I have columns called qty1, qty2, qty3, qty4 in tblZPLUSales and I want a way to add all these values on a row together and then minus this from my currentstock column in tblStock

For Example

Qty1 = 10
Qty2 = 2
Qty3 = 30
Qty4 = 11

A total: 53

Now update my tblStock taking away the 53.
UPDATE p set p.currentstock=p.currentstock-u.qty1 FROM tblStock p join tblZPLUSales u on p.id=u.id

Open in new window

0
Comment
Question by:richard_gar
[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
2 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 500 total points
ID: 24397589
UPDATE p set p.currentstock=p.currentstock- (u.qty1+ u.qty2 +u.qty3+u.qty4 )
FROM tblStock p join tblZPLUSales u on p.id=u.id
0
 

Author Closing Comment

by:richard_gar
ID: 31582005
spot on, cheers
0

Featured Post

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MySql Workbench outputting "OK" as result of queries. 5 50
SQL Syntax 6 53
Data conversion error in SSIS 3 57
T-SQL: Number of Records is Greater Than One 7 51
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

752 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