Continuing with this week's series of "punch line code" samples, I wanted to share with you this small bit of T-SQL that Tracy McKibben uncovered. It's from the same codebase that we all peeked into a number of weeks back. Anyway, if you needed a command that would delete all rows from a specific table, you'd probably do something like this:
DELETE FROM HashIndex
Or, maybe this:
TRUNCATE TABLE HashIndex
Both do the job, each behaving specially in its own special way. Tracy's colleague, however, was satisfied with neither; he wanted to extra careful not to delete rows that didn't exist ...
DELETE FROM HashIndex WHERE ItemHash >= (SELECT MIN(ItemHash) FROM HashIndex)
