Roger Steinberg
Roger Steinberg

Reputation: 1604

Exclude Rows where contains anything but a number

Objective:

Is there a simple way of excluding any result that contains anything but a number

These, for example, should be excluded:

Upvotes: 0

Views: 399

Answers (2)

shawnt00
shawnt00

Reputation: 17915

where col not like '%[^0-9]%'

or

where patindex('%[^0-9]%', col) = 0

patindex() would be most useful if you need to find the position of matches and parse the string.

Upvotes: 2

Gordon Linoff
Gordon Linoff

Reputation: 1269953

I recommend NOT LIKE:

where col NOT LIKE '%[^0-9]%'

Upvotes: 0

Related Questions