Convert Height into Feet and Inches

To convert Height into Feet and Inches

Create function InchesToFeet(@in float)

returns varchar(20)

as

Begin

declare @feet varchar(20)

set @feet  = ''

            select

                          @feet = cast(floor(V) as varchar) + ' ft' +

                          case

                                                when (@in - floor(floor(V) * 1/(2.54 / 30.48))) = 0 then

                                                            ''

                                                else

                                                            ' and '

                                                            + cast((@in - floor(floor(V) * 1/(2.54 / 30.48))) as varchar)

                                                            + ' Inches' end

            from

            (

                  select 
cast(@in * (2.54 / 30.48) as varchar) as V

            ) as d;

           return @feet;
End

 
Go

 

select dbo.InchesToFeet(68.5)