UPDATE Command with Single Records

Let’s set the new cost for the course called ‘Data Structures And Algorithms’ in ‘CoursesActive‘ Table using UPDATE Command.

Query

UPDATE CoursesActive SET courseCost = 5000
WHERE courseName = 'Data Structures And Algorithms'
SELECT * FROM CoursesActive

Output:

After UPDATE the cost of Data structures and Algorithms

Explanation: In this query, We have set the cost of ‘Data Structures And Algorithms’ as ‘5000’.

SQL Server UPDATE

SQL Server is a database engine. It works on the relational database management system (RDBMS) that allow programmer to create, manage, and manipulate data present on the relational database through their commands which is easy to learn and implement.

Similar Reads

UPDATE Command

The UPDATE operation is a part of DML (Data Manipulation Language) in SQL Server which is used for updating the existing data in the table of the database. It is one of the basic operations that gets used frequently when there needs a change in the data of the table. We can update single as well as multiple columns based on the condition we want by using the WHERE clause. The data modifications are very easy using UPDATE Commands....

How to Use the UPDATE Query?

For a better understanding of UPDATE Command with SQL Server, we need a table on which we will perform operations or queries. So here we have the CoursesActive table which contains some data as you can see in the below image. If you don’t know how to Create table in SQL Server then refer to this....

UPDATE Command with Single Records

Let’s set the new cost for the course called ‘Data Structures And Algorithms’ in ‘CoursesActive‘ Table using UPDATE Command....

UPDATE Command With Multiple Records

Example: Updating the ‘courseCost’ of all the courses with a discount of 10% in the ‘CoursesActive’ table....

Conclusion

Using theUPDATE Command in the SQL Server made it easy for the programmer to overcome their mistake as they inserted wrong information into the database or table. They can simply update their existing data with simple syntax. It ensures data integrity and data management in the relational database without harming the data or their order....

Contact Us