Wednesday

delete all duplicates in TSQL but one

     

WITH a as
(
SELECT PeriodId
,StationId
,WeekDay
,WeekCycle
,ProductId
,AssignedDate
,MenuId
,ROW_NUMBER() OVER(PARTITION by PeriodId
                        ,StationId
                        ,WeekDay
                        ,WeekCycle
                        ,ProductId
                        ,AssignedDate
                        ,MenuId ORDER BY PrimawebMenuId desc ) AS duplicateRecCount
FROM MenuProducts
)
--Deleting Duplicate Records
DELETE FROM a
WHERE duplicateRecCount > 1
    

No comments:

test smtp server with powershell

Send-MailMessage -SMTPServer smtp.domain.com -To [email protected] -From [email protected] -Subject "This is a test email" -Body ...