Trying to loop through some GUID's here. My SP works fine on it's own (EXEC sp_Send_Claim_To_Archive '146e9b9f-ad18-4303-aafb-0307083a3b03' for example). My fn_Split works fine in my other SP's so it isn't the problem either. This actually runs successfully but the archive table isn't being populated. If I replace by variable with '146e9b9f-ad18-4303-aafb-0307083a3b03' that works. Seems I can't have a variable in quotes.
DECLARE @GUIDs VARCHAR(MAX) = '146e9b9f-ad18-4303-aafb-0307083a3b03' IF LEN(@GUIDs) > 1 BEGIN DECLARE @singleGUID AS VARCHAR(50) DECLARE toUpdateGUID CURSOR FOR SELECT VALUE FROM dbo.fn_Split(@GUIDs,',') OPEN toUpdateGUID FETCH NEXT FROM toUpdateGUID INTO @singleGUID WHILE @@FETCH_STATUS = 0 BEGIN EXEC sp_Send_Claim_To_Archive '@singleGUID' FETCH NEXT FROM toUpdateGUID INTO @singleGUID END CLOSE toUpdateGUID DEALLOCATE toUpdateGUID END