Sunday, March 25, 2012

Conversion of Varchar into float

We convert a varchar column into float so that the data is ordered logically
like (1,2,10,11) instead of (1,10,11,2).
We have noticed one peculiar issue. When this query runs for a specific
range of inputs for the float values, it selects records which are outide
the inputs ranges
For example, if the query is run for float values between 1 and 10 then
values 11 is also getting pickedup besides 1 to 10. How to prevent this. ?
We tried using the float conversion part of the where clause error, but it
gives a data type conversion error . Is there any other method to order the
varchar values logically besides converting into float.
Need forum members help on this
Soura.Could you perhaps post the query so that we know what steps you are
taking to accomplish your goal?|||Hi
Check out http://www.sommarskog.se/arrays-in-sql.html to convert it into an
orderable format, you would then need to reconstitute the string.
John
"SouRa" wrote:

> We convert a varchar column into float so that the data is ordered logical
ly
> like (1,2,10,11) instead of (1,10,11,2).
> We have noticed one peculiar issue. When this query runs for a specific
> range of inputs for the float values, it selects records which are outide
> the inputs ranges
> For example, if the query is run for float values between 1 and 10 then
> values 11 is also getting pickedup besides 1 to 10. How to prevent this.
?
> We tried using the float conversion part of the where clause error, but
it
> gives a data type conversion error . Is there any other method to order th
e
> varchar values logically besides converting into float.
> Need forum members help on this
> Soura.
>
>|||Do your numbers have decimals? If not, then you should be using int and not
float.
"SouRa" <SouRa@.discussions.microsoft.com> wrote in message
news:885E2A2F-6FD6-417E-A20F-470465D574DC@.microsoft.com...
> We convert a varchar column into float so that the data is ordered
> logically
> like (1,2,10,11) instead of (1,10,11,2).
> We have noticed one peculiar issue. When this query runs for a specific
> range of inputs for the float values, it selects records which are outide
> the inputs ranges
> For example, if the query is run for float values between 1 and 10 then
> values 11 is also getting pickedup besides 1 to 10. How to prevent this.
> ?
> We tried using the float conversion part of the where clause error, but
> it
> gives a data type conversion error . Is there any other method to order
> the
> varchar values logically besides converting into float.
> Need forum members help on this
> Soura.
>
>|||We do have decmials .I forgot to mention about this in my original post
"Michael D'Angelo" wrote:

> Do your numbers have decimals? If not, then you should be using int and n
ot
> float.
> "SouRa" <SouRa@.discussions.microsoft.com> wrote in message
> news:885E2A2F-6FD6-417E-A20F-470465D574DC@.microsoft.com...
>
>|||We have solved this issue by using money instead of float
"nate.vu@.gmail.com" wrote:

> Could you perhaps post the query so that we know what steps you are
> taking to accomplish your goal?
>|||Hi
You may want to use decimal or numeric instead of money.
John
"SouRa" wrote:
[vbcol=seagreen]
> We have solved this issue by using money instead of float
> "nate.vu@.gmail.com" wrote:
>

No comments:

Post a Comment