Skip to content

Instantly share code, notes, and snippets.

@dnasca
Created January 27, 2016 09:18
Show Gist options
  • Save dnasca/6702bfe119edeb34491d to your computer and use it in GitHub Desktop.
Save dnasca/6702bfe119edeb34491d to your computer and use it in GitHub Desktop.
Multi-attribute Join - The join condition can involve more than one column from each input. Multi-attribute joins are commonly used for PK/FK associations between data sources involving more than one attribute on each side
--which rows are in the production table that are not in the archive table?
SELECT
bea.BusinessEntityId,
bea.AddressId,
bea.AddressTypeId,
bea.rowguid,
bea.ModifiedDate
FROM
Person.BusinessEntityAddress AS bea
LEFT OUTER JOIN
Person.BusinessEntityAddressArchive as abea
ON
bea.BusinessEntityId = abea.BusinessEntityId AND
bea.AddressId = abea.AddressId AND
bea.AddressTypeId = abea.AddressTypeId
WHERE
abea.BusinessEntityId IS NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment