ORDER BY text field(but that has float value in it.)
Hi Gurus, I have few excel files I loaded into sql table using ssis package. But now, I want to ORDER BY a column3 of datatype nvarchar.But the actual data coming from excel has values like 1.1, 10, 11, 1, 2.3, 2.4, 2 3, 4, 2.2 ..So, my problem is whenI do ORDER BY column3 I am getting in this order : 1, 10, 11, 2.3, 2.4, 2 3, 4, 2.2 But want to get values in this order: 1, 1.1, 2, 2.2, 2.3, 2.4 , 3, 4, 10, 11. So Please help me with this. Thanks Sparta
June 13th, 2012 9:34am

ORDER BY CAST(col AS FLOAT)Best Regards,Uri Dimant SQL Server MVP,http://sqlblog.com/blogs/uri_dimant/ Blog : MS SQL Development and Optimization Blog : Large scale of database and cleansing
Free Windows Admin Tool Kit Click here and download it now
June 13th, 2012 9:38am

Hi Sparta, I suggest you create a new column using a derived column transformation where you strip out the char , because it does not representing a proper numeric comparison for ordering, then convert it to numeric for a math based comparison, then finally order it, and then use this output to whatever target where you use the data ordered by this new column (which you are not going to use for the actual output).Arthur My Blog
June 13th, 2012 9:42am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics