sampath kumar
sampath kumar

Reputation: 11

In SQL Server can multiple tables be updated in one statement?

Can we update a data in multiple tables with one query?

UPDATE table1, table2 
SET table1.column_name = values,
    table2.column_name = values 
WHERE 
    table1.column_name = values 
    AND table2.column_name = values

Is this query correct?

Upvotes: 1

Views: 40

Answers (1)

Vahid Farahmandian
Vahid Farahmandian

Reputation: 6568

No you can not and you should write two separate Update statement. But in order to make sure that the both Updates are executed successfully, you can put them inside a transaction.

Upvotes: 3

Related Questions