Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Update query
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

240 Posts

Posted - 09/28/2012 :  13:45:16  Show Profile  Reply with Quote
Hi All,

I am having two tables T1 and T2

T1 is having Student_Id and Last_Exam_Date

T2 is having Student_Id and Exam_Date

Now i have to update T1 table with last Exam Date. Please suggest

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 09/28/2012 :  16:13:05  Show Profile  Reply with Quote
sounds like this

SET t1.Last_Exam_Date = t2.MaxDate
FROM T1 t1
INNER JOIN (SELECT Student_Id,MAX(Exam_Date) AS MaxDate
            FROM T2
            GROUP BY Student_id
ON t2.Student_Id = t1.Student_Id

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000