I’ve a query in SQL Server 2008 like this:
SELECT TOP 1 SPECIAL_CODE1 *
FROM CUSTOMERS
WHERE isnumeric(SPECIAL_CODE1)=1
ORDER BY SPECIAL_CODE1 DESC
The query result retuns as '9970'. There are rows that have a column value of '34780' or '19850'.
How can I correct my query?
‘9970’ is bigger than ‘34780’ if we are talking string values (‘9’ > ‘3’). If it’s a field defined as integer, then things are of course different. Try something like