Sql server update multiple columns from another table

Klapsius

I have read lots of post about how to update multiple columns but still can't find right answer.

I have one table and I would like update this table from another table.

Update table1 
set (a,b,c,d,e,f,g,h,i,j,k)=(t2.a,t2.b,t2.c,t2.d,t2.e,t2.f,t2.g,t2.h,t2.i,t2.j,t2.k)
from 
(
  SELECT ..... with join ... where .... 

) t2
    where table1.id=table2.id

If I running only select statement (between brackets) then script return values but not working with update

Lukasz Szozda

TSQL does not support row-value constructor. Use this instead:

UPDATE table1 
SET a = t2.a,
    b = t2.b,
    (...)
FROM 
(
SELECT ..... with join ... WHERE .... 
) t2
WHERE table1.id = table2.id

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update a column from multiple columns in SQL Server

From Dev

How to Update Table1 two columns from another table select query in MS SQL Server

From Dev

Update multiple columns of a table using aggregate values from another table

From Dev

Update multiple columns of a table using aggregate values from another table

From Dev

Copying multiple columns from one SQL table to another

From Dev

How to extract multiple rows from a table based on values from multiple columns from another table and then concatenate in SQL?

From Dev

UPDATE one SQL table based on equality of two columns with two columns from another table

From Dev

select from table and update another table SQL

From Dev

SQL : update table from another grouped table

From Dev

SQL : update table from another grouped table

From Dev

sql update table from another table snappydata

From Dev

Creating a Trigger to update another Table in SQL Server

From Dev

Sqlite: Update multiple columns from a table

From Dev

Sqlite: Update multiple columns from a table

From Dev

Getting a value from another table for multiple columns

From Dev

Update multiple columns in one table based on values in another table in mysql

From Dev

Copy multiple columns from a table to another table with extra columns

From Dev

Select data from one table & then rename the columns based on another table in SQL server

From Dev

Dynamic pivot table with multiple columns in sql server

From Dev

MYSQL - UPDATE multiple rows from another table

From Dev

SQL Comparing Two Columns in same table and update in another table

From Dev

Updating columns values from another table SQL

From Dev

SQL Update with concatenated data from another table

From Dev

Update SQL Server Database from another db

From Dev

SQL Server 2012: Is it possible to exempt some columns from triggering a history table update?

From Dev

Select multiple columns from a subquery in SQL Server

From Dev

MS SQL Server, Create and update a table based on another table

From Dev

Update multiple columns with data retrieved from multiple rows of same table

From Dev

Updating a table from another table with multiple columns in sqlalchemy

Related Related

  1. 1

    Update a column from multiple columns in SQL Server

  2. 2

    How to Update Table1 two columns from another table select query in MS SQL Server

  3. 3

    Update multiple columns of a table using aggregate values from another table

  4. 4

    Update multiple columns of a table using aggregate values from another table

  5. 5

    Copying multiple columns from one SQL table to another

  6. 6

    How to extract multiple rows from a table based on values from multiple columns from another table and then concatenate in SQL?

  7. 7

    UPDATE one SQL table based on equality of two columns with two columns from another table

  8. 8

    select from table and update another table SQL

  9. 9

    SQL : update table from another grouped table

  10. 10

    SQL : update table from another grouped table

  11. 11

    sql update table from another table snappydata

  12. 12

    Creating a Trigger to update another Table in SQL Server

  13. 13

    Sqlite: Update multiple columns from a table

  14. 14

    Sqlite: Update multiple columns from a table

  15. 15

    Getting a value from another table for multiple columns

  16. 16

    Update multiple columns in one table based on values in another table in mysql

  17. 17

    Copy multiple columns from a table to another table with extra columns

  18. 18

    Select data from one table & then rename the columns based on another table in SQL server

  19. 19

    Dynamic pivot table with multiple columns in sql server

  20. 20

    MYSQL - UPDATE multiple rows from another table

  21. 21

    SQL Comparing Two Columns in same table and update in another table

  22. 22

    Updating columns values from another table SQL

  23. 23

    SQL Update with concatenated data from another table

  24. 24

    Update SQL Server Database from another db

  25. 25

    SQL Server 2012: Is it possible to exempt some columns from triggering a history table update?

  26. 26

    Select multiple columns from a subquery in SQL Server

  27. 27

    MS SQL Server, Create and update a table based on another table

  28. 28

    Update multiple columns with data retrieved from multiple rows of same table

  29. 29

    Updating a table from another table with multiple columns in sqlalchemy

HotTag

Archive