How to Get SQL Records Starting with Numbers Only

by Updated May 12, 2018

Here's a quick SQL tip on how to get records beginning with numbers only.  Use the query string LIKE '[0-9]%'  For example:

SELECT u.UserId, u.UserName 
        FROM   dbo.aspnet_Users u WHERE u.UserName LIKE '[0-9]%'
        ORDER BY u.UserName

Keep in mind, If you are using a stored procedure and sending [0-9]% to the proc in a @Parameter, do NOT surround [0-9]% with single 'quotes', because the query may not work right (in SQL Server 2008.) 




Add your comment

by Anonymous - Already have an account? Login now!
Your Name:  

Enter the text you see in the image below
What do you see?
Can't read the image? View a new one.
Your comment will appear after being approved.

Related Posts

In SQL Server 2008 Management Studio, you may want to change the default settings to allow you to edit more than the 200 rows at a time, or select more than 1000 rows, which are the default settings for SQL Server. To modify "Edit Top 200 Rows" or "Select...  more »

I recently installed SQL Server 2008 database on my local computer and forgot to enable the common language runtime (CLR). Because I had forgotten to turn it on, some portions of my sites were not fuctioning properly due SQL Server not being able to...  more »

If you ever wanted to change a field to null in a Sql Server 2005 Management Studio result set, you're in luck because there is a quick and easy way to do it.  more »