SQL Server > Table- Create, Read, Update, Delete (CRUD)

Delete sql statement in SQL Server

How to delete a record from the Sql Server database?


To delete a record from database table, we use follow below apporach

First approach – Sql script

DELETE MyDetails
  WHERE AutoId = 2

Execute the above Delete statement in Query window and it will delete the record from MyDetails table whose AutoId value is 2.

Important

Notice the Where clause to filter the record to delete. If we forgot to mention the Where clause, it will delete all records from the database table.

Second approach - Using SSMS

Deletion can also be performed by going to the Edit mode of the database table by right clicking table name and selecting “Edit Top xxx Rows”

Now, select the row to delete by clicking on the left first blank cell and then right click the row and choose Delete or press Del button from the keyboard.

Selecting Delete opens up a confirmation dialog box

We need to click “Yes” in order to delete the record otherwise we can click on “No” to ignore it.

 Views: 7651 | Post Order: 33



Write for us






Hosting Recommendations