DML Commands in SQL Server: UPDATE

DML: Data Manipulation Language

In the earlier session we have learnt about INSERT DDL COMMAND.

Now, we will see what an UPDATE Command is and how it can be used in SQL SERVER.

As the name implies, UPDATE is a command used to update or modify or change data in a table.

Simple syntax for the update table will be as follows:

UPDATE <Table Name>
SET <Column Name> = <Value after update>

Lets say I have a table with name MYPASSWORDS (Same table which was created for Insert example).

I have the following data in MYPASSWORDS table:












Suppose If I changed password for any of my account for any reason, then that information should be reflected in MYPASSWORDS table. How could I save the latest information in MYPASSWORDS table. This is when the UPDATE command came into picture.

Using Update command , I can easily update the password which I have changes recently.

Query:

UPDATE MYPASSWORDS
SET PWD ='asderuom09'
WHERE ACCOUNTID= 'catchme@gmail.com'

After executing the above Query in SQL SERVER, password in the table should be updated with the new password.

Here is the data in the table after running the above query:'


















Sumamry:

This article explains how data can be updated using UPDATE Command in SQL Server.

This entry was posted in . Bookmark the permalink.

Leave a reply