This script outputs the TSQL code to do perform an 'Upsert'.
It depends on both the source & target tables having the same structure and rows being uniquely identified with a single field.
Three variables need to be updated prior to execution of this script:
@SourceTable: Table containing the data to be upserted
@TargetTable = Table to be upserted to
@JoinField = Unique row identifier
I'm sure this script could be taken further and/or created as a Stored Procedure if required
A short but interesting article, the author has figured out a way to create a PDF from a stored procedure without using a third party library.