| Home | Previous Lesson: The INSERT Statement Next Lesson: Cursors |
The DELETE statement can be used to delete selected entries from a database table. It can be used as follows:
Int iDelYears
iDelYears = Integer( em_DelYears.Text )
DELETE FROM trans
WHERE datediff(Year,GetDate(),tran_date) > :iDelYears;
This uses the datediff() function to check the difference, in years, between the current date and the tran_date column, in the table. It deletes any record whose difference is greater than the value in the iDelYears variable, entered by the user. Here, we could also check SQLNRows to determine the rows affected.
| Home | Previous Lesson: The INSERT Statement Next Lesson: Cursors |