473,606 Members | 2,115 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looping In SQL 2000 (Can it be a nested loop)

I have to automate a process that assigns sales leads to sales people.

For example:
Every day we buy a list of sales leads, it ranges in size from 50 -
100 records.
We have a team of sales people that also can range from 5 - 8 people.

I need to take the new records and divide them evenly among the sales
people.

If i get 50 records, and have 5 sales people, then each sales person
gets 10 leads.
--
So, im guessing that I may need to have a nested loop inside this. I
have tried it several different ways, but cant seem to get it quite
right.

DECLARE @TotalRecordCou nt int, @TotalSalesPeop leCount int,
@AmountForEach int, @LooperSalesPeo plerecords int,
@LooperNewSales LeadsRecords int, @SalesPersonID int

SELECT @TotalSalesPeop leCount = COUNT(UserId)
FROM SalesPeople
WHERE Active = 1
--
SELECT @TotalRecordCou nt = COUNT(*)
FROM NewSalesLeads
--
SELECT @AmountForEach = (@TotalRecordCo unt/@TotalSalesPeop leCount)
--
SELECT @LooperSalesPeo plerecords = 1
SELECT @LooperNewSales LeadsRecords = 1
--
WHILE @LooperSalesPeo plerecords <= @TotalSalesPeop leCount
BEGIN
WHILE @LooperNewSales LeadsRecords <= @TotalRecordCou nt
BEGIN
SELECT @SalesPersonID = (SELECT UserID
FROM SalesPeople
WHERE UniqueId = @LooperSalesPeo plerecords)

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)

UPDATE SalesLeads
SET SalesPerson_ID = @SalesPersonID
WHERE UNIQUEID = @LooperSalesPeo plerecords

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)
END
END

----
Table structures

CREATE TABLE [dbo].[SalesPeople] (
[SalesPerson_ID] [int] NOT NULL ,
[FirstName] [varchar](20)NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (26, 'Bill')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (28, 'Bob')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (37,
'Chris')
------------------------------------------------
CREATE TABLE [dbo].[SalesLeads] (
[SalesLeadID] [int]NOT NULL ,
[SalesPerson_ID] [int]NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1001,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1002,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1003,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1004,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1005,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1006,0)
------------------------------------------------

So in this case, all 3 salespeople should receive 2 salesleads each.

I dummied this down quite a bit. It actually ends up being more like
15 sales people, and about 400,000 sales leads. But it should work on
any level.

Thanks for any help you might shed on this.
Jul 20 '05 #1
6 3913
Hi

Something like this may help. It assumes the sales IDs are sequential, and
does not worry if there are a an exact division.

UPDATE L
SET SalesPerson_ID = M.SalesPerson_I D
FROM SalesLeads L JOIN
( SELECT P.[FirstName], P.[SalesPerson_ID] ,
( SELECT COUNT(*) FROM [dbo].[SalesPeople] S WHERE S.[SalesPerson_ID] <
P.[SalesPerson_ID] ) AS Rank
FROM [dbo].[SalesPeople] P ) M
ON L.SalesLeadID % ( SELECT COUNT(*) FROM [dbo].[SalesPeople] ) = M.Rank

John

"Dave" <fu*****@yahoo. com> wrote in message
news:f5******** *************** ***@posting.goo gle.com...
I have to automate a process that assigns sales leads to sales people.

For example:
Every day we buy a list of sales leads, it ranges in size from 50 -
100 records.
We have a team of sales people that also can range from 5 - 8 people.

I need to take the new records and divide them evenly among the sales
people.

If i get 50 records, and have 5 sales people, then each sales person
gets 10 leads.
--
So, im guessing that I may need to have a nested loop inside this. I
have tried it several different ways, but cant seem to get it quite
right.

DECLARE @TotalRecordCou nt int, @TotalSalesPeop leCount int,
@AmountForEach int, @LooperSalesPeo plerecords int,
@LooperNewSales LeadsRecords int, @SalesPersonID int

SELECT @TotalSalesPeop leCount = COUNT(UserId)
FROM SalesPeople
WHERE Active = 1
--
SELECT @TotalRecordCou nt = COUNT(*)
FROM NewSalesLeads
--
SELECT @AmountForEach = (@TotalRecordCo unt/@TotalSalesPeop leCount)
--
SELECT @LooperSalesPeo plerecords = 1
SELECT @LooperNewSales LeadsRecords = 1
--
WHILE @LooperSalesPeo plerecords <= @TotalSalesPeop leCount
BEGIN
WHILE @LooperNewSales LeadsRecords <= @TotalRecordCou nt
BEGIN
SELECT @SalesPersonID = (SELECT UserID
FROM SalesPeople
WHERE UniqueId = @LooperSalesPeo plerecords)

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)

UPDATE SalesLeads
SET SalesPerson_ID = @SalesPersonID
WHERE UNIQUEID = @LooperSalesPeo plerecords

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)
END
END

----
Table structures

CREATE TABLE [dbo].[SalesPeople] (
[SalesPerson_ID] [int] NOT NULL ,
[FirstName] [varchar](20)NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (26, 'Bill')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (28, 'Bob')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (37,
'Chris')
------------------------------------------------
CREATE TABLE [dbo].[SalesLeads] (
[SalesLeadID] [int]NOT NULL ,
[SalesPerson_ID] [int]NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1001,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1002,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1003,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1004,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1005,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1006,0)
------------------------------------------------

So in this case, all 3 salespeople should receive 2 salesleads each.

I dummied this down quite a bit. It actually ends up being more like
15 sales people, and about 400,000 sales leads. But it should work on
any level.

Thanks for any help you might shed on this.

Jul 20 '05 #2
John,

Yeah, we arent that concerned about having an exactly even
distribution so uneven divisors are not a problem.

And, unfortunately the sales people arent in sequential order. WE have
hundreds of sales people that are assigned to various campaigns at any
given time. So this particular campaign may change on a daily basis.
Meaning that the salespersonid is always non sequential for this
campaign.

Thanks anyway.

"John Bell" <jb************ @hotmail.com> wrote in message news:<_m******* **************@ news-text.cableinet. net>...
Hi

Something like this may help. It assumes the sales IDs are sequential, and
does not worry if there are a an exact division.

UPDATE L
SET SalesPerson_ID = M.SalesPerson_I D
FROM SalesLeads L JOIN
( SELECT P.[FirstName], P.[SalesPerson_ID] ,
( SELECT COUNT(*) FROM [dbo].[SalesPeople] S WHERE S.[SalesPerson_ID] <
P.[SalesPerson_ID] ) AS Rank
FROM [dbo].[SalesPeople] P ) M
ON L.SalesLeadID % ( SELECT COUNT(*) FROM [dbo].[SalesPeople] ) = M.Rank

John

"Dave" <fu*****@yahoo. com> wrote in message
news:f5******** *************** ***@posting.goo gle.com...
I have to automate a process that assigns sales leads to sales people.

For example:
Every day we buy a list of sales leads, it ranges in size from 50 -
100 records.
We have a team of sales people that also can range from 5 - 8 people.

I need to take the new records and divide them evenly among the sales
people.

If i get 50 records, and have 5 sales people, then each sales person
gets 10 leads.
--
So, im guessing that I may need to have a nested loop inside this. I
have tried it several different ways, but cant seem to get it quite
right.

DECLARE @TotalRecordCou nt int, @TotalSalesPeop leCount int,
@AmountForEach int, @LooperSalesPeo plerecords int,
@LooperNewSales LeadsRecords int, @SalesPersonID int

SELECT @TotalSalesPeop leCount = COUNT(UserId)
FROM SalesPeople
WHERE Active = 1
--
SELECT @TotalRecordCou nt = COUNT(*)
FROM NewSalesLeads
--
SELECT @AmountForEach = (@TotalRecordCo unt/@TotalSalesPeop leCount)
--
SELECT @LooperSalesPeo plerecords = 1
SELECT @LooperNewSales LeadsRecords = 1
--
WHILE @LooperSalesPeo plerecords <= @TotalSalesPeop leCount
BEGIN
WHILE @LooperNewSales LeadsRecords <= @TotalRecordCou nt
BEGIN
SELECT @SalesPersonID = (SELECT UserID
FROM SalesPeople
WHERE UniqueId = @LooperSalesPeo plerecords)

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)

UPDATE SalesLeads
SET SalesPerson_ID = @SalesPersonID
WHERE UNIQUEID = @LooperSalesPeo plerecords

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)
END
END

----
Table structures

CREATE TABLE [dbo].[SalesPeople] (
[SalesPerson_ID] [int] NOT NULL ,
[FirstName] [varchar](20)NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (26, 'Bill')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (28, 'Bob')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (37,
'Chris')
------------------------------------------------
CREATE TABLE [dbo].[SalesLeads] (
[SalesLeadID] [int]NOT NULL ,
[SalesPerson_ID] [int]NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1001,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1002,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1003,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1004,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1005,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1006,0)
------------------------------------------------

So in this case, all 3 salespeople should receive 2 salesleads each.

I dummied this down quite a bit. It actually ends up being more like
15 sales people, and about 400,000 sales leads. But it should work on
any level.

Thanks for any help you might shed on this.

Jul 20 '05 #3
Hi

The solution does not rely on salesperson id being sequential as it ranks
them separately. If the salesleads id are reasonably sequential then you
should be ok.

John

"Dave" <fu*****@yahoo. com> wrote in message
news:f5******** *************** ***@posting.goo gle.com...
John,

Yeah, we arent that concerned about having an exactly even
distribution so uneven divisors are not a problem.

And, unfortunately the sales people arent in sequential order. WE have
hundreds of sales people that are assigned to various campaigns at any
given time. So this particular campaign may change on a daily basis.
Meaning that the salespersonid is always non sequential for this
campaign.

Thanks anyway.

"John Bell" <jb************ @hotmail.com> wrote in message

news:<_m******* **************@ news-text.cableinet. net>...
Hi

Something like this may help. It assumes the sales IDs are sequential, and does not worry if there are a an exact division.

UPDATE L
SET SalesPerson_ID = M.SalesPerson_I D
FROM SalesLeads L JOIN
( SELECT P.[FirstName], P.[SalesPerson_ID] ,
( SELECT COUNT(*) FROM [dbo].[SalesPeople] S WHERE S.[SalesPerson_ID] <
P.[SalesPerson_ID] ) AS Rank
FROM [dbo].[SalesPeople] P ) M
ON L.SalesLeadID % ( SELECT COUNT(*) FROM [dbo].[SalesPeople] ) = M.Rank

John

"Dave" <fu*****@yahoo. com> wrote in message
news:f5******** *************** ***@posting.goo gle.com...
I have to automate a process that assigns sales leads to sales people.

For example:
Every day we buy a list of sales leads, it ranges in size from 50 -
100 records.
We have a team of sales people that also can range from 5 - 8 people.

I need to take the new records and divide them evenly among the sales
people.

If i get 50 records, and have 5 sales people, then each sales person
gets 10 leads.
--
So, im guessing that I may need to have a nested loop inside this. I
have tried it several different ways, but cant seem to get it quite
right.

DECLARE @TotalRecordCou nt int, @TotalSalesPeop leCount int,
@AmountForEach int, @LooperSalesPeo plerecords int,
@LooperNewSales LeadsRecords int, @SalesPersonID int

SELECT @TotalSalesPeop leCount = COUNT(UserId)
FROM SalesPeople
WHERE Active = 1
--
SELECT @TotalRecordCou nt = COUNT(*)
FROM NewSalesLeads
--
SELECT @AmountForEach = (@TotalRecordCo unt/@TotalSalesPeop leCount)
--
SELECT @LooperSalesPeo plerecords = 1
SELECT @LooperNewSales LeadsRecords = 1
--
WHILE @LooperSalesPeo plerecords <= @TotalSalesPeop leCount
BEGIN
WHILE @LooperNewSales LeadsRecords <= @TotalRecordCou nt
BEGIN
SELECT @SalesPersonID = (SELECT UserID
FROM SalesPeople
WHERE UniqueId = @LooperSalesPeo plerecords)

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)

UPDATE SalesLeads
SET SalesPerson_ID = @SalesPersonID
WHERE UNIQUEID = @LooperSalesPeo plerecords

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)
END
END

----
Table structures

CREATE TABLE [dbo].[SalesPeople] (
[SalesPerson_ID] [int] NOT NULL ,
[FirstName] [varchar](20)NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (26, 'Bill')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (28, 'Bob')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (37,
'Chris')
------------------------------------------------
CREATE TABLE [dbo].[SalesLeads] (
[SalesLeadID] [int]NOT NULL ,
[SalesPerson_ID] [int]NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1001,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1002,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1003,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1004,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1005,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1006,0)
------------------------------------------------

So in this case, all 3 salespeople should receive 2 salesleads each.

I dummied this down quite a bit. It actually ends up being more like
15 sales people, and about 400,000 sales leads. But it should work on
any level.

Thanks for any help you might shed on this.

Jul 20 '05 #4
I think meant to have something like this, with the keys shown and
some extra columns addded:

CREATE TABLE SalesPeople
(salesperson_id INTEGER NOT NULL PRIMARY KEY,
firstname VARCHAR(20)NOT NULL,
seq_nbr INTEGER NOT NULL,
.. );

Run this guy when then table is changed.

UPDATE SalesPeople
SET seq_nbr
= (SELECT COUNT(*)
FROM SalesPeople AS P1
WHERE P1.saleperson_i d <= SalesPeople.sal esperson_id)

Now a table for the leads as leads and not what you had:

CREATE TABLE SalesLeads
(saleslead_id INTEGER NOT NULL PRIMARY KEY,
grp_nbr INTEGER,
..);

First group the leads based on the number of sales people:

UPDATE SalesLeads
SET grp_nbr
= (SELECT COUNT(*)
FROM SalesLeads AS L1
WHERE L1.saleslead_id <= SalesLeads.sale slead_id)
% (SELECT COUNT(*) FROM SalesPeople);

Now look at a VIEW to get each sales person the group of leads they
are to work.

CREATE VIEW LeadAssignments (saleslead_id, salesperson_id)
AS SELECT L1.saleslead_id , P1.salesperson_ id
FROM Salesleads AS L1, SalesPeople AS P1
WHERE L1.grp_nbr = P1.seq_nbr;
Jul 20 '05 #5
I think I understand what you are saying here. However, This thing has
to be comletely automated and just do the update everynight.

I do appreciate the suggestions.

I have to think that this is used fairly often, and cant be this
difficult to find some folks that have written something similar.

Thanks,
Dave
jc*******@earth link.net (--CELKO--) wrote in message news:<18******* *************** ****@posting.go ogle.com>...
I think meant to have something like this, with the keys shown and
some extra columns addded:

CREATE TABLE SalesPeople
(salesperson_id INTEGER NOT NULL PRIMARY KEY,
firstname VARCHAR(20)NOT NULL,
seq_nbr INTEGER NOT NULL,
.. );

Run this guy when then table is changed.

UPDATE SalesPeople
SET seq_nbr
= (SELECT COUNT(*)
FROM SalesPeople AS P1
WHERE P1.saleperson_i d <= SalesPeople.sal esperson_id)

Now a table for the leads as leads and not what you had:

CREATE TABLE SalesLeads
(saleslead_id INTEGER NOT NULL PRIMARY KEY,
grp_nbr INTEGER,
..);

First group the leads based on the number of sales people:

UPDATE SalesLeads
SET grp_nbr
= (SELECT COUNT(*)
FROM SalesLeads AS L1
WHERE L1.saleslead_id <= SalesLeads.sale slead_id)
% (SELECT COUNT(*) FROM SalesPeople);

Now look at a VIEW to get each sales person the group of leads they
are to work.

CREATE VIEW LeadAssignments (saleslead_id, salesperson_id)
AS SELECT L1.saleslead_id , P1.salesperson_ id
FROM Salesleads AS L1, SalesPeople AS P1
WHERE L1.grp_nbr = P1.seq_nbr;

Jul 20 '05 #6
How about something like this:

----------------------------------------------------------------------
Create Table #Leads
(
LeadID Int Identity Not Null,
SalesID Int,
UniqueId Int -- Bad name
)

Create Table #SalesPeople
(
SalesID Int Identity (0, 1) Not Null,
UserID Char(30) -- type?
)
DECLARE @SalesPeopleCou nt int

-- Put sales people in the temp table.
Insert Into #SalesPeople (UserID)
Select UserID From SalesPeople Where Active = 1

-- How many were there?
Set @SalesPeopleCou nt = @@RowCount

-- Put leads in the temp table.
Insert Into #Leads (UniqueId)
Select UniqueId From NewSalesLeads

-- Match sales people to leads
Update #Leads Set SalesID = LeadID % @SalesPeopleCou nt

-- Save the matches.
UPDATE SalesLeads
SET SalesPerson_ID = UserID
From
SalesLeads
Join #Leads On SalesLeads.Uniq ueId = #Leads.UniqueId
Join #SalesPeople On #Leads.SalesID = #SalesPeople.Sa lesID
----------------------------------------------------------------------

Temporary IDs will always be sequential. The only problem with
this is that lower sales IDs will consistently get more leads.
You could fix that by adding something variable to LeadID before
performing the mod.

If you're going to use ID columns, you need to treat them as keys.
Joe Celko was using something like this as a bad example a few
weeks ago, trying to convince me that ID columns are a bad idea.
Used halfway like this, I would agree.

Bill

Dave wrote:
I have to automate a process that assigns sales leads to sales people.

For example:
Every day we buy a list of sales leads, it ranges in size from 50 -
100 records.
We have a team of sales people that also can range from 5 - 8 people.

I need to take the new records and divide them evenly among the sales
people.

If i get 50 records, and have 5 sales people, then each sales person
gets 10 leads.
--
So, im guessing that I may need to have a nested loop inside this. I
have tried it several different ways, but cant seem to get it quite
right.

DECLARE @TotalRecordCou nt int, @TotalSalesPeop leCount int,
@AmountForEach int, @LooperSalesPeo plerecords int,
@LooperNewSales LeadsRecords int, @SalesPersonID int

SELECT @TotalSalesPeop leCount = COUNT(UserId)
FROM SalesPeople
WHERE Active = 1
--
SELECT @TotalRecordCou nt = COUNT(*)
FROM NewSalesLeads
--
SELECT @AmountForEach = (@TotalRecordCo unt/@TotalSalesPeop leCount)
--
SELECT @LooperSalesPeo plerecords = 1
SELECT @LooperNewSales LeadsRecords = 1
--
WHILE @LooperSalesPeo plerecords <= @TotalSalesPeop leCount
BEGIN
WHILE @LooperNewSales LeadsRecords <= @TotalRecordCou nt
BEGIN
SELECT @SalesPersonID = (SELECT UserID
FROM SalesPeople
WHERE UniqueId = @LooperSalesPeo plerecords)

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)

UPDATE SalesLeads
SET SalesPerson_ID = @SalesPersonID
WHERE UNIQUEID = @LooperSalesPeo plerecords

SELECT @LooperSalesPeo plerecords =
(@LooperSalesPe oplerecords + 1)
END
END

----
Table structures

CREATE TABLE [dbo].[SalesPeople] (
[SalesPerson_ID] [int] NOT NULL ,
[FirstName] [varchar](20)NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (26, 'Bill')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (28, 'Bob')
INSERT INTO SalesPeople (SalesPerson_ID ,FirstName) VALUES (37,
'Chris')
------------------------------------------------
CREATE TABLE [dbo].[SalesLeads] (
[SalesLeadID] [int]NOT NULL ,
[SalesPerson_ID] [int]NOT NULL
) ON [PRIMARY]
--
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1001,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1002,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1003,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1004,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1005,0)
INSERT INTO SalesLeads (SalesLeadID,Sa lesPerson_ID) VALUES (1006,0)
------------------------------------------------

So in this case, all 3 salespeople should receive 2 salesleads each.

I dummied this down quite a bit. It actually ends up being more like
15 sales people, and about 400,000 sales leads. But it should work on
any level.

Thanks for any help you might shed on this.


Jul 20 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
16788
by: Christian Gollwitzer | last post by:
Hi, I'm trying to loop over the elements in a hashmap of the STL-implementation by SGI. The point is, that because the key/value pair is stored as std::pair in the COntainer, the code becomes very ugly and unreadable soon. I'm aware that there exists the for_each-template, but this doesn't make the code any better because the body of the for-loop must then live in an extra function (consider two nested loops). Now I tried to mimic the...
1
3714
by: Beau | last post by:
Hi all, thanks in advance. Ok, heres the story. What is happening...... -------------------------------- I've got an ASP page that loops. It loops in order to get data in different, sequential date ranges. I.E. from 9/1/2000 - 10/1/2000 then 10/1/2000 - 11/1/2000 etc etc etc. It calls SPs using the 2 dates and an integer used for companyid reference.
2
5423
by: Cappy | last post by:
I am writing an XML menu structure. I have the following XML file <MenuItems> <Item> <Name>Homepa5ge</Name> <URL>/index.aspx</URL> <Alt>Return to homepage</Alt> <Image>/images/navLocationOff.jpg</Image>
5
3365
by: Stimp | last post by:
This is a question I'm carrying over from a previous one I made today since I've simplified where the problem is... I have a datatable, tblFeatures, which has around 30 columns (one for each 'feature'). I also have between 1 and 3 rows of data (one for each 'vehicle'). I want to transpose this table so that I ouput the rows horizontally and the columns vertically.
11
2575
by: Dacuna | last post by:
Is it possible to use a recursive function to loop through a recordset faster? I have a table that I need to edit its contents after doing some calculation. The table has one field has an RawData field and a CalcData field. I open the recordset, exctract the RawData and after doing some calculations update the CalcData with the calculated data. In code I have something as follows. dim rs as new ADODB.Recordset dim cmdUpdate as new...
2
6319
by: randy1200 | last post by:
My hope is that somebody has a thought on this, or can point to toward an article that's useful. I have the following: DataSet ds = new DataSet(); ds.ReadXml("MyData.xml"); Each MainTable entry has subtable relations. Here's my current approach: foreach(DataRow row in ds.Tables.Rows {
3
2220
by: Dave128 | last post by:
Let me first start off by saying I am a beginner at Java. I need help on an assignment to produce a loop which I believe for this particular assignment would be the for loop. The output needs to look like this N 10*N 100*N 1000*N 1 10 100 1000 2 20 200 2000 3 30 300 3000 4 40 400 ...
11
4987
by: boker | last post by:
i try to do nested looping like this for (i=0;i<=640;i++) { for(j=0;j<=640;j++) { if(getpixel(j,i)!=0) { printf("this a color pixel); } }
14
6002
by: NetworkElf | last post by:
Hi all, Does anyone have some code that shows an example of how to loop through a range of IP addresses? I'm using text boxes to get a start and end value for the range. I was thinking about using 4 nested for-next loops, but I seem to be having trouble working out the logic to validate the octets in the beginning and ending address so the range works correctly. i.e. 172.16.1.1/172.20.1.1 should loop 172-172,16-20,1-254,1-254...
0
8433
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8429
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8300
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
5963
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5461
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3922
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3969
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2443
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1287
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.