• Since you literally can't add enough values here to make a cursor all that bad, you might want to use a cursor just to have better control over the processing of the values. For example, as below; note that I have not tested this code:

    CREATE PROCEDURE dbo.call_procedure (

    @multiple_weeks varchar(8000) --valid date string(s) separated by commas,e.g.,'20010101,20010108,20010115'.

    )

    AS

    --EXEC dbo.call_procedure @multiple_weeks = '20010101,20010108,20010115';

    SET NOCOUNT ON;

    DECLARE @week varchar(20)

    DECLARE @week_number int

    DECLARE cursor_weeks CURSOR LOCAL FAST_FORWARD FOR

    SELECT ds.Item, ds.ItemNumber

    FROM dbo.DelimitedSplit8k(@multiple_weeks, ',') ds

    --or, to put out an error msg if invalid date, remove this and use the code below instead

    WHERE

    ISDATE(ds.Item) = 1

    OPEN cursor_weeks

    WHILE 1 = 1

    BEGIN

    FETCH NEXT FROM cursor_weeks INTO @week, @week_number

    IF @@FETCH_STATUS <> 0

    BREAK;

    /*

    IF ISDATE(@week) = 1

    EXEC dbo.test @week

    ELSE

    BEGIN

    RAISERROR('Week number %i, with value "%s", in the input parameter is not a valid date, skipping that value.', 10, 1,

    @week_number, @week)

    END --ELSE

    */

    EXEC dbo.test @week

    END --WHILE

    DEALLOCATE cursor_weeks

    GO --end of proc

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.