简体   繁体   中英

how to change datatype of a column in sybase query?

One of my query to Sybase server is returning garbage data. After some investigations i found out that one of the columns with datatype double is causing the issue. If I don't select that particular column then the query returns correct result. The column is question is a double with laarge number of decimal places. I tried to use round function upto 4 decimal places but still i get corrupt data. How can I correctly specify the column in my query to get correct data?

I am using windows 7 box and Sybase Adaptive server enterprise driver. (Sybase client 15.5). I am using 32 bit drivers.

Sample results:

Incorrect result using sybase ASE driver on windows 7 box

"select ric_code as ric, adjusted_weight as adjweight from v_temp_idx_comp where index_ric_code='.AXJO' and ric_code='AQG.AX'"

 ric adjweight
 1 AQG.AX        NA
 2   \020        NA
 3   <NA>        NA

Correct result on windows xp box using Merant driver

 "select ric_code, adjusted_weight from v_temp_idx_comp where index_ric_code='.AXJO' and ric_code='AQG.AX'"

 ric_code adjusted_weight
 1   AQG.AX    0.3163873547

Regards, Alok

You may try convert to numeric like this:

select ric_code as ric, weight, convert(numeric(16,4), adjusted_weight) as adjweight, currency as currency 
from v_temp_idx_comp 
where index_ric_code='.AXJO'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM