Archive

Archive for May, 2018

SQL substring replacement

May 14th, 2018 No comments

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 Tags: