Advertisement

04.17.2008 at 01:41PM PDT, ID: 23332478
[x]
Attachment Details

T-SQL Update using join

Asked by vhpcomp in MS SQL Server

I have a 'person' table that has the following fields among others:
PersonID(primary key)
FirstName,
LastName,
DateOfBirth,
LicenseNumber
ClientD
LastVisitedDate

I have a second table 'Visitor History:
HistoryID (primary key)
FirstName
LastName
LicenseNumber
DateOfBirth
ClientID
DateCheckedIn

The  same person will appear multiple times in the history table.  I need to update the LastVisitedDate in the person table with th max DateCheckedIn date from the history table.  I need to join by firstname, lastname.licensenumber, clientD (migration so the personID won't work) and update the LastVisitedDate in the  person table with the MAX date from tjhe history table for that person.  I 've tried various subquerys/joins without success.  Thanks!Start Free Trial
[+][-]04.17.2008 at 01:46PM PDT, ID: 21381190

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MS SQL Server
Sign Up Now!
Solution Provided By: aneeshattingal
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628