RSS Feed

SQL Update

Examples of SQL UPDATE

1.
What happens if you remove the WHERE clause from SQL Update query:

UPDATE Emp
SET Email = 'new_email@gmail.com'

The answer is that all Email entries in the Emp table will be changed to new_email@gmail.com.

2.
Every occurrence of 'zz' in the Lastname column is updated to 'xx':

Update Employee
Set Lastname = Replace(Lastname, 'zz', 'xx')

3.
Using A SQL JOIN In A SQL UPDATE Statement
SQL JOIN In A SQL UPDATE Statement

4.
Using CASE Statements In A SQL UPDATE Query
CASE Statements in SQL UPDATE

5.
SQL update from one Table to another based on a ID match
StackOverflow

I have a database with Account Numbers and card Numbers that I match to a file to update any card numbers to account number so I only work with account numbers. I created a view linking the Table to the Account/Card db to return the Table ID and the related Account number. Now I need to update those records where the ID matches with the Account Number.

Sales_Import where the account number field needs to be updated.

LeadID AccountNumber

147 5807811235
150 5807811326
185 7006100100007267039

RetrieveAccountNumber where I need to update from

LeadID AccountNumber

147 7006100100007266957
150 7006100100007267039

6.
Oracle: Update table with multiple columns from another table
Asktom

7.
Update multiple columns in SQL with bound multi-part identifier
StackOverflow

No comments:

Post a Comment