Translate Function?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe

    Translate Function?

    Hi all

    Is there a TSQL function like Oracle's Translate function? Where:

    Translate('13,0 00
    Miles','abcdefg hijklmnopqrstuv wxyzABCDEFGHIJK LMNOPQRSTUVWXYZ , ',' ') would
    return '13000'?

    I'm trying to extract a number from a string. REPLACE doesn't quite do
    what I want.

    Thanks


  • Erland Sommarskog

    #2
    Re: Translate Function?

    Joe (heltibrand@NO_ SPAMkarpel.com) writes:[color=blue]
    > Is there a TSQL function like Oracle's Translate function? Where:
    >
    > Translate('13,0 00
    > Miles','abcdefg hijklmnopqrstuv wxyzABCDEFGHIJK LMNOPQRSTUVWXYZ , ',' ') would
    > return '13000'?
    >
    > I'm trying to extract a number from a string. REPLACE doesn't quite
    > do what I want.[/color]

    I'm not really sure how this translate() lands on the result 13000, but
    never mind. String processing is not SQL Server's strongest game. Substring
    and patindex may be your best bets.


    --
    Erland Sommarskog, SQL Server MVP, sommar@algonet. se

    Books Online for SQL Server SP3 at
    SQL Server 2025 redefines what's possible for enterprise data. With developer-first features and integration with analytics and AI models, SQL Server 2025 accelerates AI innovation using the data you already have.

    Comment

    Working...