I had the same issue as the initial poster. My use case was the following:
One table contained Date and Time of a sport event. Because I am getting information from different sources, I changed the schema of the database so I had a int value for time and datetime (or maybe just date) for the date of the sport event.
This is my query:
UPDATE Matches
SET StartTime= MatchTime.ThisMatchStartTime
FROM Matches AS M
INNER JOIN (SELECT CONVERT(int, CONVERT(varchar, DATEPART(Hour, MatchDate)) + RIGHT('00' + CONVERT(varchar, DATEPART(Minute, MatchDate)),2)) AS ThisMatchStartTime, MatchId
FROM [Matches]
WHERE SportTypeId=16) AS MatchTime ON M.MatchId=MatchTime.MatchId
WHERE StartTime > 2400
AND SportTypeId = 16;
Some explanation:
You have to give the subquery MatchStartTime a different name otherwise you get a warning/error from SQL Server.
I also had to add MatchId so I knew I was updating the correct Match.
The SportTypeId is used to separate different sports in the database.
Thanks to @astander for pointing me in the right direction. Without his post I would have struggled a bit more to end up with this solution.