Hello,
I am not good at SQL Server 2000. I have a comma-delimited list of ids. I need to see if that ID exists in a table. If it does, I want to break out of the loop with that ID saved in a variable that I can use in my stored procedure. This is what I am trying right now:
DECLARE @coreID INT
SET @coreID=NULL
DECLARE @itemID NVARCHAR(50)
DECLARE itemCursor CURSOR LOCAL FAST_FORWARD FOR
SELECT [String] AS 'itemID' FROM dbo.SplitListIntoTable(@myIDs)
OPEN itemCursor
FETCH NEXT FROM itemCursor INTO @itemID
WHILE @@FETCH_STATUS = 0 BEGIN
-- If @itemID EXISTS IN MyTable set @coreID=@itemID and Break. How do I do this?
FETCH NEXT FROM itemCursor INTO @itemID
END
CLOSE itemCursor
DEALLOCATE itemCursor
Thank you!