| | ||
| | ||
| | ||
| To | Do This |
|---|---|
| Create a DELETE statement in SQL Server Management Studio | Right-click the desired table. Select Script Table As. Select Delete To. Choose your destination. |
| Remove all rows in a table | Use TRUNCATE TABLE < Table_Name >. |
| Automatically delete rows from related tables | Add the ON DELETE CASCADE modifier to the relationship definition by selecting the CASCADE modifier in the DELETE rule. |
| Delete rows from a view | Make sure you remove rows from only one table. |
| Delete rows from several tables using a view | Implement an INSTEAD OF trigger. |
| Enhance control and security in delete operations | Encapsulate the DELETE statements in stored procedures. |
| Perform other actions while deleting data | Implement AFTER triggers on the table. |
| Control errors during database actions | Use try catch blocks to obtain information from the ERROR_xxx functions. |
| Delete data from an ADO.NET application | Use the ADO.NET Connection and Command objects. |
| Control the information displayed to the user when an error occurs | Catch the SqlClient.SqlException class and evaluate the Number value. |
| | ||
| | ||
| | ||