Home Forums SQL Server 2008 T-SQL (SS2K8) Compare the data in two tables, If Different, Update RE: Compare the data in two tables, If Different, Update

  • There are 3 rows which are different as per the sample data provided

    UPDATEOD

    SETOD.FirstName = UD.FirstName,

    OD.LastName = UD.LastName,

    OD.Birthdate = UD.Birthdate,

    OD.AreaCode = UD.AreaCode,

    OD.PhoneNumber = UD.PhoneNumber

    FROM#OriginalData AS OD

    INNER JOIN #UpdatedData AS UD

    ONOD.MemberID = UD.MemberID AND OD.LocationID = UD.LocationID

    WHEREOD.FirstName != UD.FirstName

    OROD.LastName != UD.LastName

    OROD.Birthdate != UD.Birthdate

    OROD.AreaCode != UD.AreaCode

    OROD.PhoneNumber != UD.PhoneNumber


    Kingston Dhasian

    How to post data/code on a forum to get the best help - Jeff Moden
    http://www.sqlservercentral.com/articles/Best+Practices/61537/