Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with update Select from

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have a table with existing records and need to find the name of the person in another table and get the weekenddate
So I need to update the 1st table with the date form another table
Code:
Update WeekAtAGlance 
Set WeekAtAGlance.TimeSheetSubmittedDate =q.DateEntered 
Where WeekAtAGlance.ResourceLastName = dts.ResourceLastName 
And WeekAtAGlance.ResourceFirstName = dts.ResourceFirstName
from
(Select dts.DateEntered,dts.ResourceLastName, dts.ResourceFirstName from dbo.SOWTimeSheetDateSubmitted dts
Inner join WeekAtAGlance wag on dts.ResourceLastName = wag.ResourceLastName
And dts.ResourceFirstName = wag.ResourceFirstName
Where dts.WeekEndDate ='09/01/2012' ) q
[code]

Error says 
Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'from'.
Msg 102, Level 15, State 1, Line 9
Incorrect syntax near 'q'.


DougP
 
Try something like:
Code:
Update wag 
Set TimeSheetSubmittedDate = dts.DateEntered
from dbo.SOWTimeSheetDateSubmitted dts
Inner join WeekAtAGlance wag on dts.ResourceLastName = wag.ResourceLastName
                                And dts.ResourceFirstName = wag.ResourceFirstName
Where dts.WeekEndDate ='09/01/2012'

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top