Determine if a row of column values ​​begins with a number

I have a Questions table with a Description column. Its column values ​​are as follows:

 This is First Heading, 1 This is Subheading one, 1.2 This is subheading Question This is Second heading 2 This is subheading Two. 2.1 This is Subheading Question1 

How can I determine for each row if its column value starts at 0-9?

Are there any SQL Server 2008+ features?

+7
source share
5 answers
 SELECT CASE WHEN ISNUMERIC(SUBSTRING(LTRIM(Description), 1, 1)) = 1 THEN 'yes' ELSE 'no' END AS StartsWithNumber FROM Questions 
+18
source
 SELECT * FROM Questions WHERE Description LIKE '[0-9]%' 
+5
source

You can use the following query. First, remove the extra space on the left side and get the first left character. This query returns 0 if it is not numeric, otherwise it returns 1.

 Select ISNUMERIC(Left(Ltrim('1 This is Subheading'),1)) As Number 
+1
source
 select true where cast(substring('1 This is Subheading', 1, 1) as int) between 0 AND 9 
0
source

select * from TABLE_NAME, where (YourColName, for example, "0%", YourColName, for example, "1%", YourColName, for example, "2%", YourColName, for example, "3%", YourColName, for example, "4% ", YourColName, for example," 5% ", or YourColName, for example," 6% "or YourColName as" 7% "or YourColName as" 8% "or YourColName as" 9% ")

0
source

Source: https://habr.com/ru/post/913718/


All Articles