March 9, 2011 at 7:11 am
Ok Sorted now
I excluded the rows that caused the error, and found the results still a bit big, so I aimed at compressing the data even more. I then decided to remove @Part completly which solved both problems at the same time. No More silly errors about characters not being found. Also the original Data was 55K rows. Your query compressed it to about 11K rows. By Removing @Part and the new column Part, This came to 513 rows in total. How is that for compressing data?:-D
Now I can build a function that will resolve a factor for each of rows in stock table.
March 9, 2011 at 7:49 am
My solution for what it's worth 😉
SELECTIDENTITY(INT,1,1) AS [RowNum],
PartNumber,
Factor
INTO#MyHead
FROMdbo.XlsDump
ORDER BY PartNumber, Factor
SELECT IDENTITY(INT,0,1) AS [GroupNumber],0 AS [RowNum]
INTO #MyHead2
INSERT #MyHead2 (RowNum)
SELECT a.RowNum
FROM #MyHead a
LEFT JOIN #MyHead n ON n.RowNum=a.RowNum+1
WHERE NOT (a.Factor=n.Factor)
OR n.RowNum IS NULL
ORDER BY a.RowNum ASC
SELECTa.Factor,
MIN(a.PartNumber) As [PartFrom],
MAX(a.PartNumber) As [PartTo]
FROM #MyHead2 h
JOIN #MyHead2 l ON l.GroupNumber=h.GroupNumber-1
JOIN #MyHead a ON a.RowNum BETWEEN l.RowNum+1 AND h.RowNum
GROUP BY a.Factor, h.GroupNumber
ORDER BY PartFrom
Far away is close at hand in the images of elsewhere.
Anon.
March 11, 2011 at 5:54 am
ZA_Crafty (3/9/2011)
Ok Sorted nowI excluded the rows that caused the error, and found the results still a bit big, so I aimed at compressing the data even more. I then decided to remove @Part completly which solved both problems at the same time. No More silly errors about characters not being found. Also the original Data was 55K rows. Your query compressed it to about 11K rows. By Removing @Part and the new column Part, This came to 513 rows in total. How is that for compressing data?:-D
Now I can build a function that will resolve a factor for each of rows in stock table.
Apologies. I lost track of this one. Are you all set now?
--Jeff Moden
Change is inevitable... Change for the better is not.
March 11, 2011 at 6:14 am
Yes!
Thanks a mil for that!!!
I've got another cursor running on our live system with
"No other way"
But that is low priority, and I might turn addressing that issue into an article at some stage. Cursor only picks up 10 - 15 lines at a time, so there really is no impact except for the challenge of it 🙂
I just came out of a meeting with code changes and new modules that will keep me busy until end of May, so this will only happen after that 🙂
March 11, 2011 at 6:41 am
Ok... thanks, ZA.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply