 	--Move discarded messages
 	SELECT @DiscardedQueueId = QueueId
 	FROM Queue.Queues
-	WHERE [Endpoint] = @Endpoint + N'\Discarded'
+	WHERE [Endpoint] = @Endpoint + N'/Discarded'
 	AND QueueName = @Queue
 
 	DELETE FROM Queue.Messages

	ON m.QueueId = q.QueueId
	AND q.QueueId = @DiscardedQueueId

	--Move timeout messages
	SELECT @TimeoutQueueId = QueueId
	FROM Queue.Queues
	WHERE ParentQueueId=@QueueId
	AND QueueName=N'Timeout'

	DELETE FROM Queue.Messages
	OUTPUT deleted.* INTO [Queue].[MessagesPurged](MessageId, QueueId, CreatedAt, ProcessingUntil, ExpiresAt, Processed, Headers, Payload, ProcessedCount)
	FROM Queue.Messages	m
	INNER JOIN Queue.Queues q
	ON m.QueueId = q.QueueId
	AND q.QueueId = @TimeoutQueueId

END
GO

    DECLARE @QueueId int;
	DECLARE @DiscardedQueueId int;
	DECLARE @TimeoutQueueId int;
	DECLARE @ErrorQueueId int;
        
    EXEC Queue.GetAndAddQueue @Endpoint,@Queue,null,@QueueId=@QueueId OUTPUT;
	
