Home Forums Programming General Reverse string without built in functions RE: Reverse string without built in functions

  • Here's the sampe I came up with.

    declare @STR varchar(100), @StrRev varchar(100);

    select @STR = 'able was I ere I saw elba';

    select @StrRev = coalesce(@StrRev + substring(@Str, number, 1), substring(@Str, number, 1))

    from dbo.Numbers

    where number between 1 and len(@Str)

    order by number desc;

    select @STR, @StrRev;

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon