• Now, back to business. Foxjazz is on the edge of enlightenment. I think we should cut the man some slack, because he has dropped the insults and started trying to cooperate. He was taught badly, and so learned bad habits, and we need to help unlearn him. So....

    -------------------------------------------------------------------------

    -- Pop Quiz for FOXJAZZ, just to make sure you are with us so far.

    -- Based on what you have been shown, recode this as a set based solution

    -- Hint#1: Anything with @ at the beginning must go.

    -------------------------------------------------------------------------

    create table #input (inputString varchar(100))

    create table #output (outputString varchar(100))

    insert into #input

    select 'This is how we roll.' union all

    select 'Just putting some strings in.' union all

    select 'Setting up the problem and all that.' union all

    select 'To make it easier for others to think about the problem.' union all

    select 'Paradimethylaminobenzaldehyde '

    ----------------------------------------------------------------------------

    -- Hint #2: everything between here and "select * from #output" can be

    -- replaced with ONE line of code (whitespace)

    -- or

    -- two if you put the INSERT on a separate line for readability

    -- or

    -- three if you are excessive compulsive about putting a FROM

    -- clause on its own separate line

    -- or

    -- seven, if you put every WORD on a separate line

    ----------------------------------------------------------------------------

    declare @totallyUnnecessaryAndSuperfluousVariable varchar(100)

    declare @sel cursor

    ----------------------------------------------------------------------------

    -- ever notice how the loops for open-while-fetch all look alike?

    -- wouldnt it be nice if you didnt have to fool with the boilerplate?

    -- the fun part about programming is focusing on significant code

    ----------------------------------------------------------------------------

    set @sel = cursor for

    SELECT inputString from #input

    open @sel

    fetch next from @sel into @totallyUnnecessaryAndSuperfluousVariable

    while (@@fetch_status = 0) -- so did we really read something or not?

    begin

    insert into #output (outputstring)

    values(@totallyUnnecessaryAndSuperfluousVariable)

    fetch next from @sel into @totallyUnnecessaryAndSuperfluousVariable -- didnt we do this already?

    -- doesnt it seem silly to have to repeat it?

    end

    -------------------------------------

    select * from #output

    drop table #input

    drop table #output

    __________________________________________________

    Against stupidity the gods themselves contend in vain. -- Friedrich Schiller
    Stop, children, what's that sound? Everybody look what's going down. -- Stephen Stills