Click here to Skip to main content
15,912,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1.00027e+007---->
VB
10002700.00


5.95E+15 ----->
VB
5950000000000000.00
Posted

If I understand you correctly you should always use numeric data types for numeric data. So instead of converting the data, change the underlying type.

What comes to converting the data 16 digits is a too big number for int which uses only 4 bytes. Because of this you need to use bigint.

Also the conversion needs to go through float or similar type which may cause a loss of precision.

Having that said, try something like
SQL
select cast(cast('5.95E+15' as float) as bigint)


Addition

To test if the data is numeric, consider the following
SQL
select cast(cast((case isnumeric('5.95E+15') when 1 then '5.95E+15' else null end) as float) as bigint)
select cast(cast((case isnumeric('A5.95E+15') when 1 then 'A5.95E+15' else null end) as float) as bigint)
 
Share this answer
 
v2
Comments
Wendelius 28-Jul-15 3:28am    
First of all when asking a question concerning an answer, always use the "Have a Question or Comment" button.

If you have alphanumeric data in the column, those cannot be converted. If needed you can use IsNumeric function to test the data. Have a look at the modified answer.
ok ... but in a column i am having alpha numeric as wel as float values... for wat i can do sir.
 
Share this answer
 
Comments
Dhamodharan A 28-Jul-15 5:59am    
u said you having data's in alpha numeric data's, they how you can use int here ?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900