Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Convert float to varchar

Author  Topic 

evanburen
Posting Yak Master

167 Posts

Posted - 2007-06-26 : 09:44:59
Hi -

My field TDMergerVotePercent is defined as a float field. I want it to return 'NA' when the value is -1 but I'm getting the error message

'Error converting data type varchar to float' in my aspx page. Is there where the CAST function can be used? Thanks

CASE
WHEN TDMergerVotePercent = -1 THEN 'NA'
WHEN TDMergerVotePercent IS NULL THEN ''
ELSE TDMergerVotePercent
END AS TDMergerVotePercent

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-06-26 : 09:51:31
[code]CASE
WHEN TDMergerVotePercent = -1 THEN 'NA'
WHEN TDMergerVotePercent IS NULL THEN ''
ELSE cast(TDMergerVotePercent as varchar(20))
END AS TDMergerVotePercent[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-26 : 10:39:37
Note that you cant make any calculation on those values

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

pootle_flump

1064 Posts

Posted - 2007-06-26 : 11:06:32
quote:
Originally posted by madhivanan

Note that you cant make any calculation on those values

Madhivanan

Failing to plan is Planning to fail

No "do it front end"?

You are losing your touch.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-27 : 04:23:10
quote:
Originally posted by pootle_flump

quote:
Originally posted by madhivanan

Note that you cant make any calculation on those values

Madhivanan

Failing to plan is Planning to fail

No "do it front end"?

You are losing your touch.


Yes. Sometimes I give chance to others

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -