Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delete rows if letters in cell SQL Server

Tags:

sql

sql-server

I needed some guidance as to how I can exlude rows that contains any form of letter in a cell that is supposed to contain integers only.

This is what the data looks like now:

CustomerID
----------
ea176680
27906857
62675436
62566247
1bed413e
61110053
61113323
34441416

AS you can see in the table, the first,ID contains letters. How can I remove complete rows if a cell were to contain any form of letters?

like image 785
user3197575 Avatar asked Oct 29 '25 09:10

user3197575


1 Answers

How about this where clause?

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

It filters out any values that have a non-digit. Unfortunately, SQL Server doesn't support regular expressions, but this will do what you want.

If you specifically wanted to look for letters, you can do:

where CustomerId like '%[a-zA-Z]%'
like image 56
Gordon Linoff Avatar answered Oct 31 '25 00:10

Gordon Linoff



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!