To update records into SQL Server database, we can use Update sql statement as shown below.
First approach – using SQL Script
Update MyDetails SET FullName = 'Ram Modified', City = 'City Modified' WHERE AutoId = 1
Here, we are modifying FullName and City column of the MyDetails database table record whose AutoId is 1.
Notice the Where clause, this where clause is very important. In case we forgot to mentioned the Where clause in the Update statement, all records from MyDetails table will get updated.
Always check for Where clause in the Update statement to avoid updating all records.
Second approach – using SSMS command
Choose “Edit Top xxx Rows” by right clicking the database table that opens up the table in update mode
Now modify the data by clicking on the editable cell and press Enter key to save the data.
Views: 5091 | Post Order: 32