SELECT CASE
           WHEN EXISTS (SELECT 1
                        FROM [dbo].[TaskExecutionMetadata]
                        WHERE [TaskExecutionId] = @TaskExecutionId
                          AND [Key] = @Key) THEN 1
           ELSE 0 END;
