I am trying to have a job on each server use the following stored procedure. The problem is, when I run this job on the local server, it works fine, when I run the same job on a remote server, I get an error about the "Merge" statement not being able to run against a remote database. We are running SQL 2008 R2.
MERGE INTO dbo._demo_sp_exec_stats STAT
USING 
(SELECT  d.object_id, d.database_id, 
  OBJECT_NAME(object_id, database_id) AS proc_name, 
  d.last_execution_time
  FROM sys.dm_exec_procedure_stats AS d
  WHERE d.database_id = DB_ID('_DemoDB')  ) AS SRC
ON STAT.object_id = SRC.object_id
WHEN MATCHED 
 AND STAT.last_execution_time <> SRC.last_execution_time THEN
UPDATE SET
    last_execution_time = SRC.last_execution_time
WHEN NOT MATCHED THEN
INSERT  (object_id,
 database_id,
 proc_name,
 last_execution_time)
VALUES (SRC.object_id, SRC.database_id, 
 SRC.proc_name, SRC.last_execution_time) ; 
 
    