Start Sql updating multiple columns one update statement

Sql updating multiple columns one update statement

The "tiresome way" is standard SQL and how mainstream RDBMS do it.

I am currently engaged in so doing and in SQL Server 2012 you can now update more than 1 column per @John Woo answer below.

I suspect OP just used an alias loosely because the question isn't about correctness of syntax, but "why" this syntax.

UPDATE can be used to modify one column at a time or multiple columns at a time.

So, please make sure you make the necessary changes before running the script. " clause to the above SQL in case you need to insert new records, if it does not exist.

DEPARTMENT; MERGE INTO PERSONS_TMP PT USING ( SELECT P.

if i know the email_id field is populated on some records but not on others, i can limit the update to just those rows as follows UPDATE PERSONS P SET (jobtitle, last_name, first_name, dblogin_id, email_Id, userlevel, facility_id, supervisor, department, winloginid) = (select jobtitle, last_name, first_name, dblogin_id, email_Id, userlevel, facility_id, supervisor, department, winloginid from TEMP_ECOLAB_PERSONS TE where TE.

Personally, I prefer using aliases throughout like I did here: stackoverflow.com/a/982947/27535 If you need to re-type this several times, you can do like I did once.