I have a SQL Server 2005 database with a table an ID column. When I select MAX(ID), I get only 99, but the table contains ID no's from 0 to 103. It should select 103 as max, but it returns 99. Can anyone help me out?
+4
A:
Is ID numeric? Cuz if not, '99' as a string is higher bigger than '103'... Post the schema and the query.
Remus Rusanu
2009-07-04 05:04:50
This is most likely the issue happening. You can use MAX(CAST(ID as int)) to test it.
Eric
2009-07-04 05:06:02