Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Cursors or ?

Author  Topic 

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2006-09-28 : 07:50:20
I have a Stored Procedure that show RentArrears for a tenant only
eg Execute RentArrears '88' where 88 is the tenantID
Now I want to execute it for other tenants, I want think of using Cursors to loop thru tenent table , but everybody is frowning at it, what other method can I use to loop thru tenant so as to use my stored procedure
Thanks



If it is that easy, everybody will be doing it

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-09-28 : 07:52:31
Do you want to execute that procedure for all tenantIds?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

OBINNA_EKE
Posting Yak Master

234 Posts

Posted - 2006-09-28 : 07:53:32
Yes

If it is that easy, everybody will be doing it
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-28 : 07:58:34
How did you manage to get information for tenant with ID 88?
Are you using WHERE? If so, there is no need to change SP if TenantID is the parameter passed to the SP.

If the SP is not that long, post the SP here.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2006-09-28 : 08:01:43
Obinna_exe

I've been watching a few of your threads.
You haven't given enough information for anyone to answer you properly.

Read this http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx and try to post your question with some detail. If you posted your table DDL, you might get a decent anwswer. You have asked "what other method can I use to loop", cursors are the main way to loop, but you've asked the wrong question. You probably don't need to loop, you just need to select a set... but without the information, nobody can know that.

So, give the right information and you'll get a better answer. If you don't give enough information, you will either get a really bad answer, or you will annoy people, or both.



Damian
"A foolish consistency is the hobgoblin of little minds." - Emerson
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-09-28 : 08:12:07
What has changed since this topic http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=70923 ?

Or might it be that simple as replacing your current
WHERE TenantID = @TenantID

with
WHERE (TenantID = @TenantID OR @TenantID IS NULL)

and call the stored procedure with Execute RentArrears NULL, to get all tenants arrears.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -