James Monger James Monger - 3 months ago 10
SQL Question

SQL Server : select where column only contains one character (but multiple times)

I have a table like this:

ID | Name | Description
-------|--------|--------------------------------------
1 | Bob | Lorem ipsum dolor sit amet.
2 | Alice | ??????????????
3 | Jeff | ?????
4 | Drew | Nunc iaculis lorem quis leo laoreet.
5 | John | ???????????????????????
6 | Will | What is your name? Is it James?


I want to select all rows where
Description
only contains the character
?
, but any number of times apart from 0.

In the example above, I would want to select the rows with ID
2
,
3
and
5
. I would not expect row
6
to be selected.

Answer

You are looking for this:

WHERE table.Description NOT LIKE '%[^?]%'