Skip to content

Instantly share code, notes, and snippets.

@arman-hpp
Created July 5, 2018 05:30
Show Gist options
  • Save arman-hpp/33d6cebb2dc5fd06b7c76f873a963b0d to your computer and use it in GitHub Desktop.
Save arman-hpp/33d6cebb2dc5fd06b7c76f873a963b0d to your computer and use it in GitHub Desktop.
delete duplicate by keeping original
WITH CTE AS
(
SELECT *
,ROW_NUMBER() OVER
(
PARTITION BY [CreditVerifierRoleId],[CreditRuleJobGroupId],[CreditGrade],[SalaryRate],[AveragingRate],[AveragingMonthDuration],[MaxCredit],[MaxGuaranteePerCustomer],[CreditRuleType],[BeginDate],[EndDate],[CreatedOn],[CreatedBy],[ModifiedOn],[ModifiedBy]
ORDER BY [CreditVerifierRoleId],[CreditRuleJobGroupId],[CreditGrade],[SalaryRate],[AveragingRate],[AveragingMonthDuration],[MaxCredit],[MaxGuaranteePerCustomer],[CreditRuleType],[BeginDate],[EndDate],[CreatedOn],[CreatedBy],[ModifiedOn],[ModifiedBy]
) AS RN
FROM [QTasBankDatabase].[Loan].[CreditRules]
)
DELETE FROM CTE WHERE RN<>1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment