Update statement fails

  • What I've I done wrong with this:

    update crt_student_test2

    set crt_student_test2.class_id = cactus.cactus, set crt_student_test2.ClassID_Updt = 'Y'

    where cactus.teacher = crt_student_test2.class_id

    and crt_student_test2.school_year = 2008

    and crt_student_test2.school_number = cactus.sch

    The data types match but I'm getting:

    Msg 156, Level 15, State 1, Line 3

    Incorrect syntax near the keyword 'set'.

  • Don't use two sets...

    update crt_student_test2

    set crt_student_test2.class_id = cactus.cactus,

    crt_student_test2.ClassID_Updt = 'Y'

    where cactus.teacher = crt_student_test2.class_id

    and crt_student_test2.school_year = 2008

    and crt_student_test2.school_number = cactus.sch

    You may also need a from clause and joins depending on your needs.

  • D'OH! I hope that was a result of my cold medicine and not a serious brain problem. Works just fine. Thanks.

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

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