IF COL_LENGTH('[dbo].[documento]', 'idestipulante') IS NOT NULL AND COL_LENGTH('[dbo].[controle]', 'idestipulante') IS NOT NULL
BEGIN
	UPDATE documento SET idestipulante = c.idestipulante FROM documento d INNER JOIN controle c on c.idcontrole = d.idcontrole WHERE d.idestipulante is null and c.idestipulante IS NOT NULL;
END