CREATE Procedure [dbo].[Sp_Queue_Forosh]  @MaxQ Smallint Output
AS
 DECLARE @Queue INT = 100
 SELECT @MaxQ = IsNull(Max(Queue),0) From TblQueue 
 Where Convert(varchar(10), DateDay,111) = Convert(Varchar(10), GetDate(), 111)
 IF @MaxQ = 0 
   SET @MaxQ = @Queue 
ELSE
  SET @MaxQ = @MaxQ + 1
 Insert Into TblQueue (Queue) Values(@MaxQ)
RETURN @MaxQ