Information
Total Authors: 23
Total Articles: 49
While working with Active Directory automation projects, one of the many things I run into is the need to sync multiple data sources. Usually we would perform a join using User Management Resource Administrator (UMRA). While this type of join produces 3 types of results, one being that the record is located within both data sources, it doesn't provide a method to determine which records have been modified.
I will provide a method to take 2 data sources and determine which records have been modified. If the record is within the resulting table then you will need to find out which information has changed, otherwise all of the information matches and you do not need to process the record. This method will work for any type of data; from Oracle, to SQL, or AD and CSV.
If you have a source record from the authoritative resource with information like
|
ID
|
FirstName
|
LastName
|
|
1
|
Allan
|
Bogh
|
|
ID
|
FirstName
|
LastName
|
|
1
|
Al
|
Bogh
|
SELECT *
FROM (SELECT '1' AS ID,'Allan' AS FN, 'Bogh' AS LN) AS T1
JOIN (SELECT '1' AS ID, 'Al' AS FN, 'Bogh' AS LN) AS T2
ON T1.ID=T2.ID
AND (
T1.FN<>T2.FN
OR T1.LN<>T2.LN
)
SELECT *
FROM SourceDatabase.Users AS T1
JOIN UMRADatabase.Users AS T2
ON T1.ID=T2.ID
AND (
T1.FN<>T2.FN
OR T1.LN<>T2.LN
)
SELECT T1.ID,
T1.FN,
T1.LN,
T2.ID,
T2.FN,
T2.LN
FROM SourceDatabase.Users AS T1
JOIN UMRADatabase.Users AS T2
ON T1.ID=T2.ID
AND (
T1.FN<>T2.FN
OR T1.LN<>T2.LN
)
SELECT *
FROM (SELECT ID, FN, LN FROM SourceDatabase.Users) AS T1
JOIN (SELECT ID, FN, LN FROM UMRADatabase.Users) AS T2
ON T1.ID=T2.ID
AND (
T1.FN<>T2.FN
OR T1.LN<>T2.LN
)
|
ID
|
FN
|
LN
|
ID
|
FN
|
LN
|
|
1
|
Allan
|
Bogh
|
1
|
Al
|
Bogh
|
Comments (0)