CREATE FUNCTION dbo.GetWareWeekDayString(@AWareNumber  INT)

--Created AV 20071005

/*
  The function is used in Management --->> WareGroups- ->> Wares -- >>Advanced -->>Weekdays

*/

RETURNS VARCHAR(7)
AS
BEGIN

  DECLARE  @Result VARCHAR (7)
  DECLARE  @CurrentWeekDay CHAR (1)


  DECLARE Ware_cursor CURSOR FOR

  SELECT CONVERT(CHAR(1),WeekDayNumber)  FROM WareWeekDayXTab WITH (NOLOCK)
  WHERE FK_WareNumber = @AWareNumber
  ORDER BY WeekDayNumber

  OPEN Ware_cursor
  FETCH NEXT FROM Ware_cursor INTO @CurrentWeekDay

  SET @Result = ''
  WHILE @@fetch_status = 0
  BEGIN
    SET @Result = @Result + @CurrentWeekDay
  FETCH NEXT FROM Ware_cursor INTO @CurrentWeekDay
  END

  CLOSE Ware_cursor
  DEALLOCATE Ware_cursor

  RETURN @Result

end

