How to Get SQL Records Starting with Numbers Only
Tuesday, August 24, 2010
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 AND 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.)