CREATE TABLE #RSDUP (CD_CTR_DT_MOVIMENTO INT)
INSERT INTO #RSDUP
SELECT
	CD_CTR_DT_MOVIMENTO
FROM
	EST_PROD_CPL_VD_LOTE_PROC_PENDENTE
GROUP BY
	CD_CTR_DT_MOVIMENTO
HAVING
	COUNT(CD_CTR_DT_MOVIMENTO)>1

DELETE
	P
FROM
	EST_PROD_CPL_VD_LOTE_PROC_PENDENTE P INNER JOIN #RSDUP PE ON
	P.CD_CTR_DT_MOVIMENTO = PE.CD_CTR_DT_MOVIMENTO

DROP TABLE #RSDUP
go
IF NOT EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IX_EST_PROD_CPL_VD_LOTE_PROC_PENDENTE')
BEGIN
ALTER TABLE dbo.EST_PROD_CPL_VD_LOTE_PROC_PENDENTE ADD CONSTRAINT
	IX_EST_PROD_CPL_VD_LOTE_PROC_PENDENTE UNIQUE NONCLUSTERED 
	(
	CD_CTR_DT_MOVIMENTO
	) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
END