joejack0330
Technical User
We seem to be having problems all of a sudden with a cursor locking up other users and taking a lot longer than it use too. We are dealing with small amounts of data being paased back but every where I read, it says not to use cursors so wanted to see if someone could help us a little with a different way to do the following. It seems to be the in the declare and select that is the issue because we logged some begin and end times and have it narrowed down to here so not the process where we fetch and do some other code. If we run select by itself, it seems fine and tables seem good so kind of stuck. Thanks, Joe
DECLARE SecondaryIDsInResidualZone CURSOR FAST_FORWARD FOR
SELECT tbllpa_HeaderLabelID
FROM tblLabelPalletAisles
LEFT JOIN tblLabelPalletCombinations ON
tbllpc_HeaderID = tbllpa_HeaderLabelID AND
tbllpc_CombinationNumber = @PalletCombinationNumber
WHERE tbllpa_Facility = @Facility AND
tbllpa_ResidualZone = @ResidualZone AND
tbllpa_ColumnNumber IS NULL AND
tbllpa_HeaderLabelID NOT IN (@PrimaryPalletIDPrior, @PrimaryPalletID) AND
ISNULL(tbllpc_PrimaryPallet,2) <> 1
GROUP BY tbllpa_HeaderLabelID
ORDER BY COUNT(*)
DECLARE SecondaryIDsInResidualZone CURSOR FAST_FORWARD FOR
SELECT tbllpa_HeaderLabelID
FROM tblLabelPalletAisles
LEFT JOIN tblLabelPalletCombinations ON
tbllpc_HeaderID = tbllpa_HeaderLabelID AND
tbllpc_CombinationNumber = @PalletCombinationNumber
WHERE tbllpa_Facility = @Facility AND
tbllpa_ResidualZone = @ResidualZone AND
tbllpa_ColumnNumber IS NULL AND
tbllpa_HeaderLabelID NOT IN (@PrimaryPalletIDPrior, @PrimaryPalletID) AND
ISNULL(tbllpc_PrimaryPallet,2) <> 1
GROUP BY tbllpa_HeaderLabelID
ORDER BY COUNT(*)