T-SQL

  • Hi,

    Can I replacea a range of letters or numbers from a string?

    For example

    I want to replace the string 'sdekwexnm123486' with

    '000000000123486'

    How can I do it?

    Please help me out.

  • Look up the REPLACE function in books online.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • sunandas (5/20/2008)


    Hi,

    Can I replacea a range of letters or numbers from a string?

    For example

    I want to replace the string 'sdekwexnm123486' with

    '000000000123486'

    How can I do it?

    Please help me out.

    CREATE TABLE #Temp

    (MyColumn VARCHAR(50))

    GO

    INSERT INTO #Temp

    VALUES('MyReplaceMentsdekwexnm123486')

    GO

    SELECT REPLACE(MyColumn,'sdekwexnm123486','000000000123486') FROM #Temp

    GO

    DROP TABLE #Temp

    GO

    Prasad Bhogadi
    www.inforaise.com

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply