insert @CIDS(Controlid, ControlidOrderKey)
select Controlid, ControlIDOrderKey from #CIDS order by controlidorderkey
SELECT ControlID FROM @CIDS
Shows
ControlID: 00-0385, 00-0375
DROP TABLE #CIDS
DECLARE ControlID_cursor CURSOR FOR
SELECT Controlid FROM @CIDS
OPEN ControlID_cursor
FETCH NEXT FROM ControlID_cursor INTO @ControlIdNS
SELECT @ControlIdNS AS 'ControlIdns'
Shows:
ControlID: 00-0385
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO @NoteStack
SELECT @ControlIdNS,
N.NoteID,
FROM dbo.udfActiveReportNoteInformation(@ControlIdNS, NULL, NULL, 0) udfARNI
INNER JOIN tblNote N
ON N.NoteId = udfARNI.NoteID
ORDER BY udfARNI.NoteIDSortOrder
FETCH NEXT FROM ControlID_cursor
END
Shows:
ControlID NoteID
00-0385 21897
00-0385 21930
00-0385 21897
00-0385 21930
I'm not sure why I'm not getting values for ControlID: 00-0375 (the controlid does have corresponding NoteIDs) and why NoteID: 21897 and 21930 are being repeated twice.
My main question is do I have the insert and select statement properly in the cursor.
Thanks.
select Controlid, ControlIDOrderKey from #CIDS order by controlidorderkey
SELECT ControlID FROM @CIDS
Shows
ControlID: 00-0385, 00-0375
DROP TABLE #CIDS
DECLARE ControlID_cursor CURSOR FOR
SELECT Controlid FROM @CIDS
OPEN ControlID_cursor
FETCH NEXT FROM ControlID_cursor INTO @ControlIdNS
SELECT @ControlIdNS AS 'ControlIdns'
Shows:
ControlID: 00-0385
WHILE @@FETCH_STATUS = 0
BEGIN
INSERT INTO @NoteStack
SELECT @ControlIdNS,
N.NoteID,
FROM dbo.udfActiveReportNoteInformation(@ControlIdNS, NULL, NULL, 0) udfARNI
INNER JOIN tblNote N
ON N.NoteId = udfARNI.NoteID
ORDER BY udfARNI.NoteIDSortOrder
FETCH NEXT FROM ControlID_cursor
END
Shows:
ControlID NoteID
00-0385 21897
00-0385 21930
00-0385 21897
00-0385 21930
I'm not sure why I'm not getting values for ControlID: 00-0375 (the controlid does have corresponding NoteIDs) and why NoteID: 21897 and 21930 are being repeated twice.
My main question is do I have the insert and select statement properly in the cursor.
Thanks.