Answers for "update multiple columns sql"

SQL
-1

update table sql multiple set

-- CANT do multiple sets but can do case
UPDATE table
SET ID = CASE WHEN ID = 2555 THEN 111111259 
              WHEN ID = 2724 THEN 111111261
              WHEN ID = 2021 THEN 111111263
              WHEN ID = 2017 THEN 111111264
         END
WHERE ID IN (2555,2724,2021,2017)
Posted by: Guest on April-08-2021
0

sql update from two different database

update table_name1
set column_name = T2.column_name
from database_name.dbo.table_name2 as T2
  where table_name1.ID = T2.ID
Posted by: Guest on August-26-2020
0

sql query update multiple columns

UPDATE table_name SET column1 = value1, column2 = value2,... 
WHERE condition;

table_name: name of the table
column1: name of first , second, third column....
value1: new value for first, second, third column....
condition: condition to select the rows for which the 
values of columns needs to be updated.
Posted by: Guest on September-28-2021
0

sql update multiple tables

/*You can't update multiple tables in one statement,
however, you can use a transaction to make sure that
two UPDATE statements are treated atomically.
You can also batch them to avoid a round trip.*/


BEGIN TRANSACTION;

UPDATE Table1
  SET Table1.LastName = 'DR. XXXXXX' 
FROM Table1 T1, Table2 T2
WHERE T1.id = T2.id
and T1.id = '011008';

UPDATE Table2
SET Table2.WAprrs = 'start,stop'
FROM Table1 T1, Table2 T2
WHERE T1.id = T2.id
and T1.id = '011008';

COMMIT;
Posted by: Guest on April-20-2021

Code answers related to "update multiple columns sql"

Code answers related to "SQL"

Browse Popular Code Answers by Language