Do:
SELECT LOCATE('{', SEUCAMPO), LOCATE('}', SEUCAMPO)
FROM SUATABELA;
SELECT SUBSTRING(SEUCAMPO,LOCATE('{', SEUCAMPO), LOCATE('}', SEUCAMPO))
FROM SUATABELA;
SELECT REPLACE(SEUCAMPO,SUBSTRING(SEUCAMPO,LOCATE('{', SEUCAMPO), LOCATE('}', SEUCAMPO)),'')
FROM SUATABELA;
There is no need to 1º
and 2º SELECT
, is just a demonstration of how each function will return its value. I have separated the Fiddle
so that you can better understand how the whole process works, explaining:
- Find the position of
{
and }
using the function LOCATE
.
- Through the position use
SUBSTRING
to extract the part you want to remove.
- Now just use the function
REPLACE
, replacing by ''
.
Note: For this solution to work in MSSQL
just change the function LOCATE
for CHARINDEX
, both are equivalent.