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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 numeric to varchar problem with parameter

Author  Topic 

pvong
Yak Posting Veteran

58 Posts

Posted - 2010-10-10 : 19:55:37
I'm a newbie.

I have a case inside a case and I need to convert all the numeric values to varchar. I have no problem with this as long as I use actual numbers. I have a problem when I add a parameter to my formula and taking out one of the whole numbers I manuall put in. The parameter is @Px and it's used twice in the case statement.

here is my Case:
CASE WHEN OnePercentAssignment.BuyOption IS NULL THEN (CASE WHEN ((Total * (2.5 / @Px) / 100) - Quantity) > 0 THEN CONVERT (varchar(50) , ROUND(((Total * (2.5 / @Px) / 100) - Quantity) , 0)) ELSE '0' END) ELSE OnePercentAssignment.BuyOption END

This is the error msg I got:



------------------------------
Using VS2008 / Learning in VB.Net 2.0 / Win2003 / SQL 2005 w SP2
Be kind to the newbies because you were once there.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-10-11 : 12:59:10
Could you try it in Management Studio instead of VS? I believe VS is limited in the complexity of the queries that it can handle.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -