Using cursors to populate a column

  • I am trying to populate a column with date/time info, I am doing this so I can use getdate() on the data for other computations (the format is mon/day/yr/hours/mins, i was told only data having mon/day/yr format can be used with getdate()). The code below says that dateyest is an invalid object name. Actually, any kind of insert I do reports the same error, no matter what column it is (securty on my account is all set, as well as for the stored proc.). I must be overlooking something very simple, right? thanks for the help!DECLARE @dateYest datetime

    DECLARE Cur668 CURSOR

    Keyset

    FOR

    SELECT cast(date1 as datetime) dt

    FROM baclosetable

    OPEN Cur668

    fetch next from cur668 into @dateyest

    WHILE @@FETCH_STATUS = 0

    BEGIN

    if @dateyest is not null

    Insert dateyest VALUES (@dateYest)

    fetch next from cur668 into @dateyest

    END

    CLOSE Cur668

    DEALLOCATE Cur668

  • quote:


    i was told only data having mon/day/yr format can be used with getdate


    Actually this is an incorrect statement. Barring what you did here what is the ultimate goal to do with GETDATE() in regards to your data?

    "Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)

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

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