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
 Error converting data type varchar to numeric.

Author  Topic 

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2007-10-17 : 11:39:54
I am having problems with a statment that I am writing.
The prop_uac is a alpha field and prop_disc is a numeric field. What I was trying to do is when the alpha field is not populated automatically pull from the numeric field. Then I wanted to put all of the results into one column. Can this be done? below is my statement. I hope you can help me.

Prop_uac =
CASE
WHEN prop_uac = '' THEN prop_disc
else prop_uac
End

X002548
Not Just a Number

15586 Posts

Posted - 2007-10-17 : 11:44:21
the result of a case statement must have consistent datatypes

use

Prop_uac =
CASE
WHEN prop_uac = '' THEN CONVERT(varchar(25),prop_disc)
else prop_uac
End


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

werhardt
Constraint Violating Yak Guru

270 Posts

Posted - 2007-10-17 : 13:20:35
Thank you Brett! You were a great help.
Go to Top of Page
   

- Advertisement -