Bulk Record Update with SQL

前端 未结 5 1458
你的背包
你的背包 2020-12-05 02:48

I have two tables in a SQL Server 2008 environment with the following structure

Table1
- ID
- DescriptionID
- Description

Table2
- ID
- Description
<         


        
5条回答
  •  悲&欢浪女
    2020-12-05 03:11

    Your approach is OK

    Maybe slightly clearer (to me anyway!)

    UPDATE
      T1
    SET
      [Description] = t2.[Description]
    FROM
       Table1 T1
       JOIN
       [Table2] t2 ON t2.[ID] = t1.DescriptionID
    

    Both this and your query should run the same performance wise because it is the same query, just laid out differently.

提交回复
热议问题