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
 how to use loop in store procedure

Author  Topic 

ameya_amu
Starting Member

25 Posts

Posted - 2009-04-10 : 11:29:04
i have one Manager_master with following fields

Managerid
Managername
SeniorManagerid





i have another table managercommission_master

level
commission


i have another table manager commission which store commission ofeach manager


on entry in manager_master i need to distribute commission to their superior up to 7 level


please help me out to create a storeprocedure which pick commision from managercommission_master and make entry in managercommission,
suggest if i should change table structure

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2009-04-11 : 07:32:49
I would sugegst add a column on managercommison_master called "managerid"
What columns do you currently have in on the manager commission table?

Jack Vamvas
--------------------
http://www.ITjobfeed.com
Go to Top of Page

ameya_amu
Starting Member

25 Posts

Posted - 2009-04-11 : 07:41:36
i have manager name and commissionearned field in manager commission.

eg.

i have manager id with 3 and its superior manager is 2 and manager2 is subordinate of 1 this is the manager hierarchy. i have commission level for level 1 commission is 50 for level2 commission is 20 and for level3 commission is 10 level4 commission 5. when manager 3 is entered manager 2 will earn commission of 50 and manager 1 will earn commission of 20.
this is what i want to store in three table. please help me out. i want store procedure that will automatically calculate the commission when new manager is entered.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-12 : 13:42:50
are you using sql 2005? if yes, look for recursive common table expressions

http://msdn.microsoft.com/en-us/library/ms186243.aspx
Go to Top of Page
   

- Advertisement -