update using a self join?

  • Is it possible to do an update statement using a self join? We are currenlty using a cursor.

    I have oversimplified the example:

    UPDATE table_x

    SET b.elig_end_Date = a.elig_end_Date+1

    FROM table_x a, table_x b

    WHERE a.elig_tag<>b.elig_tag

    Thanks!

    -K

  • I got it,sorry:

    UPDATE table_x

    SET end_Date = b.end_Date

    FROM table_x , table_x b

    WHERE table_x.elig_tag<>b.elig_tag and table_x.elig_tag=1

  • Glad to hear, duplicate message see responses in http://www.sqlservercentral.com/forum/topic.asp?TOPIC_ID=5463&FORUM_ID=8&CAT_ID=1&Topic_Title=can+you+UPDATE+with+a+self+join&Forum_Title=T%2DSQL[/url as well.

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

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

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