MS SQL Server 2012 - DBA Articles

UPDATE - Modify Existing Records with Conditional Data



UPDATE statement is used to modify existing data values in one or many or all of the records to a table. UPDATE statement does not generate query result set. SELECT query must be run before and after UPDATE statement to know the modified data values. The following queries are used to UPDATE particular Product Name and Remark data value in PRODUCT Table.

-- Example 24 --

 

SELECT * FROM Product

WHERE Prod_Code = 'PROD4'

 

UPDATE Product SET

Prod_Name = 'Product N',Remarks = 'Remark N'

WHERE Prod_Code = 'PROD4'

 

SELECT * FROM Product

WHERE Prod_Code = 'PROD4'


Query Output Screen

* * * * *


Email Your Comment To AUTHOR