IF  COL_LENGTH('[dbo].[documento]', 'NegocioCorretora') IS NOT NULL AND EXISTS(SELECT 1 FROM [dbo].[documento] WHERE [NegocioCorretora] IS NULL)
BEGIN
	UPDATE [dbo].[documento] SET [NegocioCorretora] = CASE WHEN(situacao = 2 AND idnegocio IS NOT NULL AND idnegocio = 1) THEN 1 ELSE 0 END WHERE [NegocioCorretora] IS NULL
END