
Untitled
By: a guest on
May 26th, 2012 | syntax:
None | size: 0.65 KB | hits: 13 | expires: Never
SQL Server stored proc - need to return resultset before execution finishes
BEGIN
DECLARE @ID int
IF EXISTS(
SELECT ID
FROM Competitions
WHERE COALESCE(Won, 0) != 1
AND WinningTime < GetDate()
)
BEGIN
--If we have a winner then select the row (whilst locking the table to prevent multiple winners), then update the row to mark the competition as being won
BEGIN TRAN
--Select row
--Update row to mark it as 'Won'
COMMIT TRAN
--** We need to return the previous select before executing this **
WAITFOR DELAY '000:10:00'
EXECUTE ResetCompetition @CompID = @ID;
END
END