Translate

Friday, 28 September 2018

Delete duplicate row in sql , T-SQL: Deleting all duplicate rows but keeping one [duplicate]

  WITH cte AS (
  SELECT child_code,
     row_number() OVER(PARTITION BY child_code ORDER BY child_code) AS 'Duplicatecount'
  FROM SDMIS_STUDENT_MASTER_18_19  where SchoolRegNo='1234567' and Class=6
   and isnull(child_code,'')<>'')
DELETE cte WHERE Duplicatecount > 1

No comments:

Post a Comment