How to detect if a string contains at least a number (digit) in SQL server 2005?
To check if a string contains at least one number using regex, you can use the \d regular expression character class in JavaScript. The \d character class is the simplest way to match numbers.
To find whether a given string contains a number, convert it to a character array and find whether each character in the array is a digit using the isDigit() method of the Character class.
To check if a string contains a number in Python:Use the str. isdigit() method to check if each char is a digit. Pass the result to the any() function. The any function will return True if the string contains a number.
To check if a string contains numbers in JavaScript, call the test() method on this regex: /\d/ . test() will return true if the string contains numbers. Otherwise, it will return false .
Use this:
SELECT * FROM Table WHERE Column LIKE '%[0-9]%'
MSDN - LIKE (Transact-SQL)
DECLARE @str AS VARCHAR(50) SET @str = 'PONIES!!...pon1es!!...p0n1es!!' IF PATINDEX('%[0-9]%', @str) > 0 PRINT 'YES, The string has numbers' ELSE PRINT 'NO, The string does not have numbers'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With