On SQL Server (2008), I have a column which is varchar(max).
I want to query for all rows where the blurb contains a lettered list:
Some sentence is here
a. foo
b. bar
c. baz
Some more text later
Can do this easily in regular expressions, but I do not have access to add regex capabilities to my instance.
So, How can I search using LIKE to find something like this? Presumably I would need to find where the first character of the line (in a multi-line blurb) is a character and 2nd is a dot.
Best Answer
You might have to play with
CHAR(13)
andCHAR(10)
depending on the source of the text, but this might be simply:Note this will also find:
If you need to only return rows where there is a list with two or more lines, you may not want to do this in the database, because it would require much more complicated parsing. In fact in that case - and if I couldn't perform the parsing outside the database (or in the database with CLR RegEx), I would probably use an ordered split function.