x
login about faq Site discussion (meta-askssc)

Convert Text to decimal.

how to handle below error,

Operand type clash: text is incompatible with decimal

i must data trans for text datatype to decimal data type. in first table all values are decimals.

more ▼

asked Apr 17 '12 at 05:24 AM in Default

prasad.nyalapatla gravatar image

prasad.nyalapatla
90 1 3 7

(comments are locked)
10|1200 characters needed characters left

1 answer: sort oldest

I would suggest you stop using the text datatype and instead use the varchar(max) datatype.

But to cast from text to decimal you'll have to go over a varchar. Like this:

SELECT CAST(CAST(textColumn as varchar(max)) as decimal(10,5))
FROM someTable
more ▼

answered Apr 17 '12 at 06:02 AM

Magnus Ahlkvist gravatar image

Magnus Ahlkvist
13.7k 13 17 30

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1613

asked: Apr 17 '12 at 05:24 AM

Seen: 350 times

Last Updated: Apr 17 '12 at 06:02 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.