MySQL, Tips and TricksSQL substring replacement

SQL substring replacement

There are times when you need to replace only a part of the string in the database column.
You can use the stuff() function in MSSQL or insert() function in MySQL

MSSQL

 Definition: STUFF ( string , start , length , replaceWith )
 Example: select stuff('My Original String', 4, 8, 'Replaced'); 
 Output: My Replaced String

MySQL

 Definition: INSERT( string, start, length, replaceWith )
 Example: select insert('My Original String', 4, 8, 'Replaced');
 Output: My Replaced String

Categories: MySQL, Tips and Tricks

Comments

No Comments Yet. Be the first?

Post a comment

Your email address will not be published. Required fields are marked *