Using TSQL variables in For Loop expression

  • I'm trying to convert an SP that does a lot of bulk copying into an SSIS package.

    I need to loop through the records of a table but not the whole table so I dont think I can use a loop through recordset. I want to loop from 0 to 75000.

    In the SP, I set the loop up like this:

    SELECT @RowID= MIN(RowID)

    FROM FunctionLog_Heap WITH (NOLOCK)

    SELECT@MaxRowID = @RowID + 75000

    WHILE @RowID <= @MaxRowID

    BEGIN

    main processing goes here

    SELECT @RowID = @RowID + 1

    END

    How do I replicate this loop in SSIS and be able to perform processing on each row?

    I'm new to SSIS so assume I know nothing.

    Thanks

    Matt

  • While this article doesn't directly answer your question and assumes some level of SSIS knowledge - it should point you in the right direction. In this example the author is using a timer, you should be able to replace with a rowcount transformation or int32 value from another variable.

    http://www.sqlis.com/310.aspx

  • At the risk of sounding trite - why don't you just call the SP from within SSIS? Is there something you're trying to get away from?

    ----------------------------------------------------------------------------------
    Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply