Finding strings containing a% character in a table

How to find rows containing a character '%'

in a table column.

For example, I have a column that contains data like 'amylase 50% of dose'

.

How do I select and filter all rows containing a character %

in a given column?

+3


source to share


4 answers


try this query



select * from tablename where columnname like '%[%]%'

      

+3


source


You can use WHERE Id LIKE '%[%]%'

. An example would be something like this:

CREATE TABLE #Test
(
Id NVARCHAR(100)
)

INSERT INTO #Test VALUES ('100%'), ('1000')

SELECT * FROM #Test
WHERE Id LIKE '%[%]%'

DROP TABLE #Test

      



OUTPUT:

Id
100%

      

+2


source


We use the clause / operator to find / match anything in the columns. Below query will look for "%" at start / middle / end or can say everywhere in the column value.

select * from tablename where columnname like '%[%]%'.

      

+1


source


Try the following,

select * from tablename where columnname like '%\%%'

      

0


source







All Articles