General information
Forum:
Microsoft SQL Server
Environment versions
SQL Server:
SQL Server 2008
>I have some fields in a table which contain numeric values but are defined as Char(3). So, in some SQLs, we have this ORDER BY Field1, Field2. Is there an easy way to obtain the order by as per the numeric value instead of their textual values? The problem is that values such as 1, 10, 11 which appear before 2, 3 instead of 1, 2, 3, 10, 11.
Include also the converted/cast-to-numeric field in your select fields clause, and then order by that field instead of the character one.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only