x

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, 2012 at 05:24 AM in Default

prasad.nyalapatla gravatar image

prasad.nyalapatla
100 4 6 10

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

1 answer: sort voted first

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, 2012 at 06:02 AM

Magnus Ahlkvist gravatar image

Magnus Ahlkvist
16.4k 16 19 33

(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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

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

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1834

asked: Apr 17, 2012 at 05:24 AM

Seen: 828 times

Last Updated: Apr 17, 2012 at 06:02 AM