Skip to content
Advertisement

SQL Server – grab part of string after a value sequence

I have a table called Note with a column named Notes.

It has font info in the beginning which I don’t need. I’ve created a new column name final_notes and would like to grab everything after the “fs” plus two characters. The final result would be

Advertisement

Answer

We use PATINDEX to find the first occurrence of fs followed by two digits.

We null it out if we get a 0 i.e. we cannot find the string.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement