Join and update same column sql server

This question already has an answer here:

  • How do I UPDATE from a SELECT in SQL Server? 27 answers

  • Use update with join :

    update b
    set b.value = a.id
    from tableb b 
      join tablea a on b.value = a.value
    
  • SQL Fiddle Demo

  • In SQL Server, you can do this with a join in the update . The specific syntax in your case is:

    update b
        set value = a.id
        from tableb b join
             tablea a
             on b.value = a.value;
    
    链接地址: http://www.djcxy.com/p/16862.html

    上一篇: SQL Server 2005冻结(因为应用程序),需要记录

    下一篇: 加入并更新同一列sql服务器