Created
June 3, 2013 19:45
-
-
Save Dillie-O/5700786 to your computer and use it in GitHub Desktop.
Advanced Remove Duplicate Row Delete Snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DELETE application_versions FROM | |
( | |
SELECT TOP (@duplicate_count - 1) id | |
FROM application_versions | |
WHERE (@application_id IS NULL OR application_id = @application_id) | |
AND (@lock_version IS NULL OR lock_version = @lock_version) | |
AND (@asset_id IS NULL OR asset_id = @asset_id) | |
AND (@customer_id IS NULL OR customer_id = @customer_id) | |
AND (@received_date IS NULL OR received_date = @received_date) | |
AND (@fee_amount IS NULL OR fee_amount = @fee_amount) | |
AND (@created_at IS NULL OR created_at = @created_at) | |
AND (@updated_at IS NULL OR updated_at = @updated_at) | |
) AS t1 | |
WHERE application_versions.id = t1.id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment