IF	COL_LENGTH( '[dbo].[documento]', 'banco' ) IS NOT NULL AND COL_LENGTH( '[dbo].[documento]', 'idbanco' ) IS NOT NULL
BEGIN
	IF (SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'documento' AND COLUMN_NAME = 'idbanco' AND DATA_TYPE = 'int') IS NOT NULL
		 BEGIN
			 UPDATE [dbo].[documento] 
			 SET idbanco = TRY_CAST ( banco AS INT ) 
			 WHERE
			 (
				 SELECT	idcodigobanco FROM codigobanco 
				 WHERE idcodigobanco = TRY_CAST ( banco AS INT )
			 ) IS NOT NULL AND banco IS NOT NULL AND banco != '' AND idbanco IS NULL;
		END
END