select NCM_NFE,Origem,Cfop,TaxaTributaria,Icmf,SubstTributaria,CSOSN,Cest,RegraCalculo,Cst_Confins,Cst_Icms,CST_NFE,
Cst_pis,Aliq_Confins,Aliq_ecf,Aliq_icms_iss,Aliq_pis,Reducao_bc_icms from tblProduto  
where not NCM_NFE = ''
group by NCM_NFE,Origem,Cfop,TaxaTributaria,Icmf,SubstTributaria,CSOSN,Cest,RegraCalculo,Cst_Confins,Cst_Icms,CST_NFE,
Cst_pis,Aliq_Confins,Aliq_ecf,Aliq_icms_iss,Aliq_pis,Reducao_bc_icms
having Count(NCM_NFE)=1

select NCM_NFE from tblProduto  
where not NCM_NFE = ''
group by NCM_NFE

select * From REGRASTRIBUTARIAS.dbo.tblLUCROREALRESTAURANTE 

delete from REGRASTRIBUTARIAS.dbo.tblLUCROREALRESTAURANTE 

select  NCM_NFE From REGRASTRIBUTARIAS.dbo.tblLUCROREALRESTAURANTE 
group by NCM_NFE
having Count(NCM_NFE) > 1

delete from REGRASTRIBUTARIAS.dbo.tblLUCROREALRESTAURANTE
where NCM_NFE in
  (select NCM_NFE from REGRASTRIBUTARIAS.dbo.tblLUCROREALRESTAURANTE
   group by NCM_NFE
   having Count(NCM_NFE)>1)
and not idcod in
  (select Min(idcod) from REGRASTRIBUTARIAS.dbo.tblLUCROREALRESTAURANTE
   group by NCM_NFE
   having Count(NCM_NFE)>1)



	
