• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1214
  • Last Modified:

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

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
davidi1
Asked:
davidi1
  • 2
1 Solution
 
tigin44Commented:
use
ROUND(coulumnName, 1)
0
 
tigin44Commented:
sory I missed a point... try this

ROUND(CAST(coulumnName AS FLOAT), 2)
0
 
davidi1Author Commented:
Bingo. Thank you
0
 
sshah254Commented:
try convert(decimal(10,2), waittime)

Ss
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now