Share via

Query - remove braces

Kumar 21 Reputation points
2021-02-07T19:55:32.323+00:00

I need the below output. Please provide a query for this.

64930-image.png

Output

64918-image.png

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL

A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.

0 comments No comments

Answer accepted by question author

Erland Sommarskog 134.3K Reputation points MVP Volunteer Moderator
2021-02-07T20:43:28.233+00:00
SELECT CASE WHEN charindex('{', col) > 0
       THEN substring(col, 1, charindex('{', col) - 1)
       ELSE col
FROM tbl

The query simply removes all text that comes after the first left brace (and the brace itself), no matter whether this brace is matched by a right brace or not.

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.