Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sql server how to check if a string contains letters only?

I have a column of nvarchar look like this

col
--------
123hello45
12345
hello

Expect output

col
--------
hello

Azure Synapse doesn’t support regular expression. How can I find out if the rows contains letters only?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

We can use SQL Server’s enhanced LIKE operator here:

SELECT col
FROM yourTable
WHERE col NOT LIKE '%[^A-Za-z]%';

The logic here is any col value which does not have one or more non letter characters therefore must be only letters.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading