Search
 
SCRIPT & CODE EXAMPLE
 

SQL

sql update multiple columns

UPDATE table_name SET column1=value1, column2=value2 WHERE condition
Comment

sql update multiple columns from another table

-- Oracle
UPDATE table2 t2 SET (VALUE1, VALUE2) = 
    (SELECT COL1 AS VALUE1, COL1 AS VALUE2 FROM table1 t1 WHERE t1.ID = t2.ID);
-- SQL Server
UPDATE table2 t2 SET
    t2.VALUE1 = t1.COL1,
    t2.VALUE2 = t1.COL2
FROM table1 t1
INNER JOIN t2 ON t1.ID = t2.ID;
-- MySQL
UPDATE table2 t2 INNER JOIN table1 t1 USING (ID)
SET T2.VALUE1 = t1.COL1, t2.VALUE2 = t1.COL2;
Comment

sql server update multiple columns at once

UPDATE Person.Person
 Set FirstName = 'Kenneth'
    ,LastName =  'Smith'
 WHERE BusinessEntityID = 1
Comment

update multiple columns in sql

UPDATE table-name SET column-name = value, column-name = value WHERE condition = value
Comment

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)
Comment

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;
Comment

sql server alter multiple columns

ALTER TABLE tblcommodityOHLC alter column CC_CommodityContractID NUMERIC(18,0);
ALTER TABLE tblcommodityOHLC alter column CM_CommodityID NUMERIC(18,0);
Comment

PREVIOUS NEXT
Code Example
Sql :: alter table query sql server change column 
Sql :: delete top 10 rows in sql 
Sql :: sql server select another database 
Sql :: oracle select row max date 
Sql :: sqlite show columns 
Sql :: get largest number in database sql 
Sql :: full join sql 
Sql :: sql server 2019 installation 
Sql :: sql column name 
Sql :: oracle create table primary key 
Sql :: oracle select invalid views 
Sql :: SQL Subquery and JOIN 
Sql :: SQL Updating a View 
Sql :: mssql-cli usage 
Sql :: mysql query where in 
Sql :: oracle list primary key 
Sql :: truncate your answer to decimal places mysql 
Sql :: sql find leading space 
Sql :: sql server version check 
Sql :: temp tables in sql server 
Sql :: python sqlite3 search 
Sql :: substring sql 
Sql :: how to find total working hour in sql 
Sql :: postegresql update to null 
Sql :: datagrip execute procedure 
Sql :: sql select whole row max column 
Sql :: how to comment in sql 
Sql :: insert into postgres 
Sql :: How to check if a column exists in a SQL Server table? 
Sql :: creating sql table 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =