February 12, 2013 at 8:19 am
I'm looking at some code for the first time, and am puzzled (happens a lot). The cursor "Membership_Cursor gets declared based on a table variable that I assume is empty. So how can the later "OPEN MembersDup_Cursor" and
"FETCH NEXT FROM MembersDup_Cursor" do any processing ?
CREATE PROCEDURE [dbo].[Deduplicate] (@OldMemberStatus_ID INT, @NewMemberStatus_ID INT)
AS
DECLARE @KeepMemberID INT, @Email VARCHAR(128), @CurrentMemberStatusID INT,
@DuplicateMemberID INT, @AutoDedupLogID INT, @KeepMemberStatus_ID INT, @OldMemberStatus_ID INT, @NewMemberStatus_ID INT
@DuplicateMemberStatus_ID INT
DECLARE @MembersKeep TABLE (MemberID INT,
Email VARCHAR(128),
ActualCreationDate DATETIME)
DECLARE @MembersDupe TABLE (KeepMemberID INT,
Email VARCHAR(128),
DupeCount INT,
DayDiff INT,
KeepActualCreationDate DATETIME,
DuplicateMemberID INT,
DuplicateActualCreationDate DATETIME,
DuplicateMemberStatus_ID INT)
DECLARE MembersDup_Cursor CURSOR FOR
SELECT DISTINCT KeepMemberID, Email, DuplicateMemberID, DuplicateMemberStatus_ID
FROM @MembersDupe
ORDER BY Email
February 12, 2013 at 8:40 am
It would help if you post the entire SP's code, but i would assume, that the table variable gets populated before the cursor gets opened.
The cursor gets populated by the open statement, not by the declare.
Hope this helped.
BR
February 12, 2013 at 8:43 am
That explains it, thanks
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply