• well this is what was done to accomplish it. inelegant as it seems to me.

    1. generates the SQL YearQuarter list.

    declare YRQList cursor for

    SELECT DISTINCT YearQuarterID from CCSGen.dbo.vwODSSM_YearQuarter where YearQuarterID between @YRQSTART and @YRQMax and firstClassDay < GETDATE() and YearQuarterID >= @YRQStart

    2. runs thru a series of updates for each column in order.

    DYN2 = fixing nulls to 0's

    DYN3 = where they are NOT null put a 1

    DYN4 = because of the progression i can update the YRQStart field if there is a 1 in the current YRQ column and YRQSTART is null. (being first occurrance)

    OPEN YRQList

    FETCH NEXT FROM YRQList

    INTO @YRQ

    WHILE @@FETCH_STATUS = 0

    BEGIN

    DECLARE @DYN2 as nvarchar(4000)

    DECLARE @DYN3 as nvarchar(4000)

    DECLARE @DYN4 as nvarchar(4000)

    SET @DYN2 = 'UPDATE [CCSIRDev].[dbo].[CCSRetention] SET [' + @YRQ + ']=''0'' WHERE [' + @YRQ + '] IS NULL'

    SET @DYN3 = 'UPDATE [CCSIRDev].[dbo].[CCSRetention] SET [' + @YRQ + ']=1 WHERE [' + @YRQ + '] <> ''0'''

    SET @DYN4 = 'UPDATE CCSRetention SET YRQStart = ''' + @YRQ + ''' WHERE [' + @YRQ + '] = 1 and YRQStart IS NULL'

    PRINT '#1:' + @DYN2

    EXEC sp_executesql @DYN2

    PRINT '#2:' + @DYN3

    EXEC sp_executesql @DYN3

    PRINT '#3:' + @DYN4

    EXEC sp_executesql @DYN4

    print 'Column Update Complete ' + @YRQ

    --PRINT @DYN2

    FETCH NEXT FROM YRQList INTO @YRQ

    END

    CLOSE YRQList

    DEALLOCATE YRQList

    now there is probably a few ways that this could be solved... maybe better? this most definitely works though.