Unix Technical Forum

Error converting data type varchar to float

This is a discussion on Error converting data type varchar to float within the SQL Server forums, part of the Microsoft SQL Server category; --> I have created a stored procedure that contain this field (below) in order to meet certain criteria. But my ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 06:13 AM
jaYPee
 
Posts: n/a
Default Error converting data type varchar to float

I have created a stored procedure that contain this field (below) in
order to meet certain criteria. But my problem is when I try to run
the stored procedure I encounter an error "Error converting data type
varchar to float".

CASE Final WHEN 0 THEN '--' ELSE Final END AS FinalGrade

The Final field is a float data type.

Could anyone teach me how to fix this problem?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-29-2008, 06:13 AM
Tzvika Barenholz
 
Posts: n/a
Default Re: Error converting data type varchar to float

Hi JayPee

You case statement is illegal because '--' is actually a varchar.
what do you want the return to be ? what is the function.

you could cast final as varchar and then return something like

when '0' then '--' else cast(final as varchar)

or if you need to keep it as float, i suggest putting null instead of
'--' and then running is_null on that.

hope this helps
Tzvika

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:43 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com