ciao Nicola,
prova a creare le tabelle che ti ho mostrato nel post precedente, esattamente come le vedi con gli stessi campi e stessi dati.
La table1 la metti nel db in locale, la table2 nel db server.
Non serve che tu crei il db sul server basta anche un percorso locale, per spostare il tutto sul server e' sufficiente modificare il path per questa prova.
Copia/incolla questo predicato sql che segue, modificando opportunamente il path del db esterno ( quello sul server per intenderci che per questa prova sara'in locale impostando il path corretto ovviamente...).
Come ti dicevo e' un po' complesso…..
SELECT "Conflicting data" AS Category,
T.id, T.nome,
T.position AS PreviousPosition,
T2.position AS NewPosition,
T.feedbackdate AS PreviosuFeedbackdate,
T2.feedbackdate AS newFeedbackdate
FROM
( table1 AS T
left JOIN
( select * from table2 AS T in 'C:\fullPath\DB_SERVER.accdb') AS T2
ON
T.id = T2.id )
inner JOIN
(SELECT T3.id,
T3.nome,
T4.position AS previousPosition,
T3.position AS newPosition,
T4.feedbackdate AS previousFeedbackdate,
T3.feedbackdate AS newFeedbackdate
FROM ( select * from table2 AS T in 'C:\fullPath\DB_SERVER.accdb') AS T3
left JOIN table1 AS T4
ON
T3.id = T4.id
WHERE
T4.id Is Null or t3.position<>t4.position or (t3.position is null and t4.position is not null) or (t3.position is not null and t4.position is null) or (t3.position is null and t4.position is null) ) AS T5
ON
T5.id=T.id
UNION ALL
SELECT "Unmatched Table 2 row",
t6.id,
t6.nome,
table1.position AS previousPosition,
t6.position AS newPosition,
table1.feedbackdate AS previousFeedbackdate,
t6.feedbackdate AS newFeedbackdate
FROM
( select * from table2 AS T in 'C:\fullPath\DB_SERVER.accdb') as T6
LEFT JOIN
table1
ON
t6.id = table1.id
WHERE
table1.id Is Null
UNION ALL SELECT "Unmatched Table 1 row",
table1.id,
table1.nome,
t7.position AS previousPosition,
table1.position AS newPosition,
t7.feedbackdate AS previousFeedbackdate,
table1.feedbackdate AS newFeedbackdate
FROM
table1
LEFT JOIN
( select * from table2 AS T in 'C:\fullPath\DB_SERVER.accdb') as T7
ON
table1.id = t7.id
WHERE
t7.id Is Null;
UNION ALL SELECT "Perfect match",
table1.id,
table1.nome,
t8.position AS previousPosition,
table1.position AS newPosition,
t8.feedbackdate AS previousFeedbackdate,
table1.feedbackdate
FROM
table1
INNER JOIN
( select * from table2 AS T in 'C:\fullPath\DB_SERVER.accdb') as T8
ON
(table1.position = t8.position) AND (table1.id = t8.id);
ciao, Sandro.