Advertisement

10.23.2007 at 04:58PM PDT, ID: 22913426
[x]
Attachment Details

SQL looping - Calling a procedure for each record

Asked by citnetworks in SQL Query Syntax, MS SQL Server

Tags: sql, procedure, each, record

I have a table with the following data. I want to compare the value of column Expense to the value of column Budget. If column Expense > column Budget I want to execute additional code.

Any insight on the best way to do this would be greatly appreciated.

I am trying to develop a stored procedure in MS SQL Server 2000.


ID      Description            Budget            Expense
0      Group Taxes & Fees      NULL            100
1      Local                  250            337.51
2      Long Distance            NULL            NULL
3      Data                  239            238.51
4      Internet            NULL            NULL
5      Management            NULL            NULL
6      Maintenance            NULL            NULL
7      Integrated            NULL            NULL
8      Television            NULL            NULL
9      Conference Callings      NULL            NULL
10      Equipment            NULL            NULL
11      test                  NULL            NULL
12      Cell Phone            NULL            NULL
13      SmartRing            NULL            NULL


So far I have:

SELECT * FROM table_1 WHERE (Expense>Budget)

I am unsure as to how to execute a procedure based on the values for each row besides using a user function. I need to perform an operation based on the Description, Expense and Budget values.


Thanks for the help.
Start Free Trial
 
Loading Advertisement...
 
[+][-]10.23.2007 at 05:09PM PDT, ID: 20135563

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: SQL Query Syntax, MS SQL Server
Tags: sql, procedure, each, record
Sign Up Now!
Solution Provided By: bitxbitvt
Participating Experts: 1
Solution Grade: A
 
 
[+][-]10.23.2007 at 05:47PM PDT, ID: 20135688

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628