all groups > sql server programming > september 2004 >
You're in the

sql server programming

group:

Is there record set solution for this?



Is there record set solution for this? Farmer
9/20/2004 10:55:10 PM
sql server programming: Thank you for any comments, help and your time

I am searching for any way to accomplish this with the record set solution.

declare @MaxPartsPerBatch int
set @MaxPartsPerBatch = 400
declare @tmp table
(
ordID int not null PRIMARY KEY
, ordCustRequestDate datetime not null
, Part_Qty int not null
, BatchID int null
)
set nocount on

INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10209, '20040924 00:00:00.000', 142, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10211, '20040924 00:00:00.000', 5, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10213, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10215, '20040924 00:00:00.000', 36, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10217, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10219, '20040924 00:00:00.000', 28, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10221, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10223, '20040924 00:00:00.000', 27, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10225, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10227, '20040924 00:00:00.000', 6, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10229, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10231, '20040924 00:00:00.000', 28, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10233, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10235, '20040924 00:00:00.000', 35, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10237, '20040924 00:00:00.000', 4, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10239, '20040924 00:00:00.000', 4, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10241, '20040924 00:00:00.000', 1, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10243, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10245, '20040924 00:00:00.000', 26, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10247, '20040924 00:00:00.000', 3, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10249, '20040924 00:00:00.000', 16, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10251, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10253, '20040924 00:00:00.000', 6, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10255, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10257, '20040924 00:00:00.000', 64, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10259, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10261, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10263, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10265, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10267, '20040924 00:00:00.000', 36, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10269, '20040924 00:00:00.000', 4, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10271, '20040924 00:00:00.000', 27, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10273, '20040924 00:00:00.000', 33, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10275, '20040924 00:00:00.000', 4, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10277, '20040924 00:00:00.000', 35, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10279, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10281, '20040924 00:00:00.000', 31, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10283, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10285, '20040924 00:00:00.000', 38, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10287, '20040924 00:00:00.000', 4, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10289, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10291, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10293, '20040924 00:00:00.000', 62, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10295, '20040924 00:00:00.000', 6, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10297, '20040924 00:00:00.000', 16, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10299, '20040924 00:00:00.000', 34, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10301, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10303, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10305, '20040924 00:00:00.000', 30, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10307, '20040924 00:00:00.000', 2, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10309, '20040924 00:00:00.000', 18, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10311, '20040924 00:00:00.000', 43, NULL)
INSERT INTO @tmp ([ordID], [ordCustRequestDate], [Part_Qty], [BatchID])
VALUES (10313, '20040924 00:00:00.000', 2, NULL)
Re: Is there record set solution for this? alien2_51
9/21/2004 1:25:07 PM
You could do this with ADO, but why...?

Dan


[quoted text, click to view]
Re: Is there record set solution for this? Farmer
9/21/2004 11:15:28 PM
Thanks for your comment
I am not sure I follow you. I am looking for a T-SQL solution that will load
balance the load (Part_Qty) , assign batchID to particular order by date,
not to exceed 400 parts per batch. That is factory business requirement that
I have been requested to implement. This is what the factory is willing to
process in one batch. This is not some theoretical mind challange I try to
solve.

Cursor way work OK but in my experience, it is often slower than the rowset
(recordset) solution. I provied just a sample record set but it normally may
be much larger.

Please clarify your question and I will try to explain.

[quoted text, click to view]
Re: Is there record set solution for this? alien2_51
9/22/2004 8:29:37 AM
Sorry misunderstood your question, when you said record set I assumed you
meant ADO, my mistake...

[quoted text, click to view]
Re: Is there record set solution for this? Hugo Kornelis
9/22/2004 11:33:25 PM
[quoted text, click to view]

(snip)

Hi Farmer,

I just posted a reply to a similar question, posted a couple of days ago
but with diifferent numbers. Let me know if you can't find it.

Best, Hugo
--

AddThis Social Bookmark Button