Created
July 25, 2012 15:11
-
-
Save mattiaswolff/3176681 to your computer and use it in GitHub Desktop.
Mediusflow: Unlock reserved tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE e | |
SET e.reservedby = NULL | |
FROM ERRAND e | |
INNER JOIN ERRAND_HISTORY eh ON (e.ID = eh.ERRANDID | |
AND eh.Tag = 'ERRAND_RESERVED') | |
WHERE e.RESERVEDBY IS NOT NULL | |
AND eh.MODIFIEDDATE < DATEADD(MINUTE, -60, GETDATE()) | |
AND eh.ID = | |
(SELECT top 1 ID | |
FROM ERRAND_HISTORY | |
WHERE ERRANDID = e.ID | |
ORDER BY ID DESC) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment