Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How to replace six chracters from middle from any string ??

How to replace six chracters from middle from any string ??

Scheduled Pinned Locked Moved Database
tutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abhishek kumar121
    wrote on last edited by
    #1

    Hi, There is column for mobile number in my table whose data type is string. I have to replace six character from middle with star(*) from the string of 10 characters. For example The Contact number is 9334459875 I have to display it as follows 93******75 first two characters and last two characters only.

    L P K 3 Replies Last reply
    0
    • A Abhishek kumar121

      Hi, There is column for mobile number in my table whose data type is string. I have to replace six character from middle with star(*) from the string of 10 characters. For example The Contact number is 9334459875 I have to display it as follows 93******75 first two characters and last two characters only.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      SELECT LEFT(PhoneNumber, 2) + '******' + RIGHT(PhoneNumber, 2)
      FROM AdventureWorks.Person.PersonPhone

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      1 Reply Last reply
      0
      • A Abhishek kumar121

        Hi, There is column for mobile number in my table whose data type is string. I have to replace six character from middle with star(*) from the string of 10 characters. For example The Contact number is 9334459875 I have to display it as follows 93******75 first two characters and last two characters only.

        P Online
        P Online
        PIEBALDconsult
        wrote on last edited by
        #3

        If SQL Server: PRINT STUFF( '9334459875' , 3 , 6 , '******' )

        1 Reply Last reply
        0
        • A Abhishek kumar121

          Hi, There is column for mobile number in my table whose data type is string. I have to replace six character from middle with star(*) from the string of 10 characters. For example The Contact number is 9334459875 I have to display it as follows 93******75 first two characters and last two characters only.

          K Offline
          K Offline
          Kiran Upadhyay
          wrote on last edited by
          #4

          SELECT STUFF('9334459875',3,6,'******')

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups