Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 671149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:20:30+00:00 2026-05-14T00:20:30+00:00

goal: I have the string 1234432144 I want to only replace the first 2

  • 0

goal: I have the string “1234432144” I want to only replace the first 2 4’s with ’10’ so I would get ‘1231032144’

Is there a way to do this in tsql?

so far I have come up with the tsql substring() function

substring('1234432144', 4, 2) 

which draws the 44 .. however how do i replace it within the existing string?

If i wrap a replace function around it, it replaces all occurrences of 44 in the string.

any ideas?

thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:20:30+00:00Added an answer on May 14, 2026 at 12:20 am

    Edited with a paremeterised version.

    DECLARE @myStr VARCHAR(50)
    DECLARE @findStr VARCHAR(50)
    DECLARE @replaceStr VARCHAR(50)
    
    SET @myStr = '1234432144'
    SET @findStr = '44'
    SET @replaceStr = '10'
    
    SELECT STUFF(@myStr, CHARINDEX(@findStr, @myStr), LEN(@findStr), @replaceStr)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: aaa bbb There is a space before the
I have a problem with this LC-3 program, I can't get the string to
Have a xml string, goal is to replace an xml element value to a
Let me first describe my goal: I have created an object with 3 properties:
My goal is to have the url routing as following: http://www.abc.com/this-is-peter-page http://www.abc.com/this-is-john-page What is
I'm using this in conjunction with the tablesorter plug-in, my goal is to have
My eventual goal is to have a string like def newline = 'C:\\www\web-app\StudyReports\\test.bat' but
I have a string like this: // string1 horse|cow|goat|zebra| and another string like this:
Goal I have a generic class GenericClass<T> and I want to pool instances. I'm
I have a string and need to get a specific chunk of text out

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.