Skip to content

Instantly share code, notes, and snippets.

@bergquist
Created October 13, 2011 12:34
Show Gist options
  • Save bergquist/1284128 to your computer and use it in GitHub Desktop.
Save bergquist/1284128 to your computer and use it in GitHub Desktop.
Merge into
merge into Customer.Address as Target
using Customer.AddressUpdates as Source
on Target.CustomerNumber=Source.CustomerNumber
when matched then
update set Target.FirstName = Source.FirstName,
Target.LastName = Source.LastName,
Target.StreetAddress = Source.StreetAddress,
Target.Email = Source.Email,
Target.IsVip = Source.IsVip,
Target.GroupRabat = Source.GroupRabat,
Target.City = Source.City,
Target.ZipCode = Source.ZipCode,
Target.Salution = Source.Salution,
Target.Phonenumber = Source.Phonenumber,
Target.BirthDate = Source.BirthDate
when not matched then
insert (CustomerNumber, FirstName, LastName, StreetAddress, Email, IsVip, GroupRabat, City, ZipCode, Salution, Phonenumber, BirthDate)
values (Source.CustomerNumber, Source.FirstName, Source.LastName, Source.StreetAddress, Source.Email, Source.IsVip, Source.GroupRabat, Source.City, Source.ZipCode, Source.Salution, Source.Phonenumber, Source.BirthDate);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment