--select 'delete top (' + convert(varchar,count(*)-1) +') from [RC_DEB_NOSSO_NUMERO] where cd_bc = '+ convert(varchar,cd_bc) +' and nosso_numero = '+ convert(varchar,nosso_numero) from [RC_DEB_NOSSO_NUMERO] group by cd_bc, nosso_numero having count(cd_bc) > 1 and count(nosso_numero) > 1



IF EXISTS (SELECT * FROM SYS.INDEXES WHERE NAME = 'IX_RC_DEB_NOSSO_NUMERO_NOSSO_NR')
BEGIN   
	DROP INDEX [IX_RC_DEB_NOSSO_NUMERO_NOSSO_NR] ON [dbo].[RC_DEB_NOSSO_NUMERO]
END

CREATE UNIQUE NONCLUSTERED INDEX [IX_RC_DEB_NOSSO_NUMERO_NOSSO_NR] ON [dbo].[RC_DEB_NOSSO_NUMERO]
(
	[CD_BC] ASC,
	[NOSSO_NUMERO] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
