I'm using SQL Server 2008.
I have a table with a column of type VarChar
. It is currently filled with strings which actually represent numbers. Unfortunately, the column must remain VarChar ('1', '2' ... , '1000' )
.
I wish to query that field for the max number value but since this is a VarChar
I get the Lexicographical max and not the natural order max.
I thought I'll try and solve this by using the COLLATE
clause for that query and change to a collation that provides numerical natural order like in this link
- Is there a collation like this for SQL Server 2008 and if so, what should be the query?
- If a collation like this exists should I use this method or should I use cast?
Thanks.