CREATE FUNCTION dbo.GetStringFixedLength (@AValue VARCHAR(100), @ALength INT)
RETURNS VARCHAR(255) AS  
/*
    Created By: A 2006 0106 Used From SP : ReturnReservationInfoToReservationLog

    Last Updated:	
    AV 2007 0412 use Trim

*/
BEGIN 
IF @Avalue IS NULL
  set @Avalue = ''

SET @AValue =RTRIM( LTRIM(@AValue))

DECLARE @Idx INT

 IF LEN(@AValue) < @Alength
 BEGIN
   SET @Idx = LEN(@AValue)
   WHILE @Idx <=@ALength-1 
    BEGIN
      SET @AValue = @AValue + char(32)
      SET @Idx = @idx + 1
    END
 END 
 ELSE IF LEN(@AValue) > @Alength
   SET @AValue = SUBSTRING(@AValue,1,@Alength)

  RETURN @AValue

END

