1

I have a MSSQL table with large number of alpha numeric codes. I have to verify these codes are within certain characters. How do I write a SQL in MSSQL? Any advice ?

Codes Table

JFBBB22 -> Valid

JBBYB33 

AXBBB22 ->Invalid

LBBBB33 

Code I am using in c# to validate..

Regex.IsMatch(code, "^[BCDFGHJKLMNPQRSTVWXZ123456789]*$").
0

2 Answers 2

1

WHERE code NOT LIKE '%[^BCDFGHJKLMNPQRSTVWXZ123456789]%'

Sign up to request clarification or add additional context in comments.

1 Comment

Perfect..That's what I wanted.. I was struggling with regex in select.
0

You can do it like this:

select dbo.RegexMatch( N'123-45-6789', N'^\d{3}-\d{2}-\d{4}$' )

For the full documentation check The MSDN site for the official page

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.