IF EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'vendedorparcela')
BEGIN
	UPDATE vendedorparcela
	SET dataprepagto = p.datarec 
	FROM vendedorparcela vp
	INNER JOIN repasse r on r.idrepasse = vp.idrepasse
	INNER JOIN parcela p on p.idparcela = vp.idparcela
	WHERE vp.datapgt IS NULL AND r.forma = 1 AND p.datarec IS NOT NULL AND vp.DATAPREPAGTO != p.DATAREC;
END