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

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Need SQL Help

Author  Topic 

itnagaraj
Yak Posting Veteran

70 Posts

Posted - 2011-05-18 : 07:00:27
Is it correct below sql statement?

Update tblRequestDetails as c Set a.WorkCompleteDate=B.ModifiedDatetime
from
(
Select B.ModifiedDatetime,A.Requestid From
(
select max(id) id,requestid from tblRequestHistory
Where RequestStatus=3
group by requestid
) A, tblRequestHistory B
Where A.id = B.id
and B.ModifiedDatetime is not null
) as z
Where c.requestid=z.requestid

but not executed

V.NAGARAJAN

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2011-05-18 : 07:11:53
Maybe

Update tblRequestDetails
Set WorkCompleteDate=B.ModifiedDatetime
from tblRequestDetails c
join
(
Select B.ModifiedDatetime,A.Requestid
From
(
select max(id) id,requestid from tblRequestHistory
Where RequestStatus=3
group by requestid
) A
join tblRequestHistory B
on A.id = B.id
and B.ModifiedDatetime is not null
) z
on c.requestid=z.requestid


==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -