By DB4, DB5 you mean servers not databases which the names here are confusing.
Nevertheless, if you have access to DB4 and DB4 is selecting from DB5, that means DB5 is a linked server registered in DB4 with a user who has a query permission on DB5 databases and MAY have insert/update/delete/create objects permissions. If so, then you can create a table in DB5.database_name
as follows:
CREATE TABLE DB5.database_name.dbo.Table_Flag(Uflag bit NOT NULL)
GO
INSERT INTO DB5.database_name.dbo.Table_Flag(Uflag) values (0)
then you can create a trigger for the updating table in DB5-Database which will update the Uflag
to 1 if there are any newly updated/inserted/deleted rows
Then you can modify the job in DB4 as:
declare @count int
set @count = (select count(*) fromDB5.database_name.dbo.Table_Flag where Uflag = 1)
if (@count > 1)
begin
TRUNCATE Table_Name
INSERT INTO Table_Name
SELECT field_name1,field_name2 ......
FROM DB5.database_name.table_Name
UPDATE DB5.database_name.dbo.Table_Flag SET Uflag = 0
end