Question of the week: string manipulation in T-SQL

Oopps! Upgrade your browser pretty please.Oopps! Upgrade your browser pretty please.

Here is a good piece of food for thought: How do you replace only the first occurrence of a character in a string with another one, disregarding of how many occurrences there are?

Here is the question explanation: You have a string, which contains any number of characters, separated by _ (underscores) . For an example,  abca1_bcd_esj. The goal is to write a T-SQL code which replaces only the first _ (underscore) with ! (exclamation point), but leave the second underscore untouched. For example, the T-SQL script will return abca1!bcd_esj from the given example string above. So far so good, but here is the catch: the T-SQL code has to replace the first occurrence of the _ (underscore), and nothing else. And even if the string contains only one underscore, it still has to be replaced.

Sounds simple? The first one who posts a correct answer gets a golden star! 🙂