IF EXISTS(SELECT 1 FROM [dbo].[vendedorparcela] WHERE [valortotal] = 0)
BEGIN	
	UPDATE vendedorparcela 
	SET valortotal =
CASE	
	WHEN ( d.ADINACOMIS = 1 ) THEN
	( d.PR_LIQ + PR_ADIC ) * ( d.com01 * 0.01 ) * ( vrep * 0.01 ) ELSE d.PR_LIQ * ( d.com01 * 0.01 ) * ( vrep * 0.01 ) 
END 
FROM
	vendedorparcela vp
	INNER JOIN documento d ON d.iddocumento = vp.iddocumento 
WHERE
vp.valortotal = 0;
END