Pregunta

I have a SQL Server 2008 R2 database with a table called productmanufacturers, with columns of ID, Name. I want to get all records where the Name column begins with a number.

I have tried the following, but it is messy and I am thinking too cumbersome. Is there a more reduced way of writing the query?

Current Query:

select * from productmanufacturers where Name like '0%' or Name like '1%' or Name like '2%' or Name like '3%' or Name like '4%' or Name like '5%' or Name like '6%' or Name like '7%' or Name like '8%' or Name like '9%'
¿Fue útil?

Solución

try this !

select * from productmanufacturers where Name like '[0-9]%'

DEMO

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top