?
Solved

Convert a scientific notation varchar to a decimal field in MS-SQL

Posted on 2005-05-13
2
Medium Priority
?
2,628 Views
Last Modified: 2008-01-09
Hi there;

I have a field in my table (I'm using MS-SQL) that is a varchar, in it is a scientific notation like : 3.5E+1. I now want to update a decimal field with this number, in this case it would be inserted in the decimal field as 35.  I tried to use cast but it doesn't work.

Has anyone done this before? Can you help?
Thanks
0
Comment
Question by:IngridK
2 Comments
 
LVL 28

Accepted Solution

by:
rafrancisco earned 500 total points
ID: 13999060
Try casting it first to float then to decimal:

select CAST(cast('3.5E+1' as float) AS DECIMAL(18, 4))
0
 

Author Comment

by:IngridK
ID: 13999143
That was great, thank you. Used it in my query to update.
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question