Sql updating multiple tables simultaneously
Suppose we have two tables Categories and Categories_Test. The common column in the two tables is CATEGORY_ID. Please note that query below is used for illustration purpose because Category_ID alone is primary key.
We are going to update column DESCRIPTION and PICTURE in table Categories_Test by using data in table Categories, based on data in the common column CATEGORY_ID. Update data in a column in table A based on a common column in table B. Update data in two columns in table A based on a common column in table B. Conditionally update data in table A based on a common column in table B. No portion may be reproduced without my written permission.
Here are the relevant clips from the MSDN documentation (emphasis is mine).
you'd have to go UPDATE Table1 , Table2 SET Table1. XXXXXX' WHERE T1= T2DECLARE @ids TABLE (id int); BEGIN TRANSACTION UPDATE Table1 SET Table1. XXXXXX' OUTPUT INTO @ids WHERE T1.field = '010008'; UPDATE Table2 SET Table2.
WAprrs = 'start,stop' FROM Table2 JOIN @ids i on = Table2.id; COMMIT; Sorry, afaik, you cannot do that.
But you can do this creating an instead of trigger on a view in a different way." id="ctl00_m_m_i_ctl00_gr_ctl03_bestanswerbody" class="textarea-bestanswerhidden" name="bestanswerbody" answerbody Id="1960381" / You cannot update a multiple tables in a single statement.
Thanks Shaik" id="ctl00_m_m_i_ctl00_gr_ctl05_bestanswerbody" class="textarea-bestanswerhidden" name="bestanswerbody" answerbody Id="1963389" /storing the same data in two different tables?