Solved

SQL - Query Help - Convert Varchar to numeric / decimal(10,2)

Posted on 2011-03-14
4
1,142 Views
Last Modified: 2012-08-14
Team,

I have 2 columns, Waittime & Sessiontime - both are Varchar(255)

it has values like 1.23545578. I have cross checked the entire table. It doesnt have any non-numeric value.

How can I limit the value to decimal(10,2).

When I cast the column as decimal, it throws "Error converting data type varchar to numeric."

Pls help
0
Comment
Question by:davidi1
  • 2
4 Comments
 
LVL 26

Expert Comment

by:tigin44
ID: 35133533
use
ROUND(coulumnName, 1)
0
 
LVL 26

Accepted Solution

by:
tigin44 earned 500 total points
ID: 35133552
sory I missed a point... try this

ROUND(CAST(coulumnName AS FLOAT), 2)
0
 
LVL 2

Author Closing Comment

by:davidi1
ID: 35133554
Bingo. Thank you
0
 
LVL 9

Expert Comment

by:sshah254
ID: 35133563
try convert(decimal(10,2), waittime)

Ss
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Detach & Attach method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

867 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now