Solved

sql with qty slash price

Posted on 2014-02-10
4
296 Views
Last Modified: 2014-02-10
Error converting data type varchar to numeric
,'BasePrice'=Case when BaseStorePrice = 1 then BaseStorePrice
else  CAST((CAST(BaseStoreQty AS VARCHAR(100))) AS VARCHAR(100)) + convert( varchar(30), '/' ) + CAST(BaseStorePrice AS VARCHAR(100)) end

Open in new window

0
Comment
Question by:sevensnake77
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 25

Expert Comment

by:Lee Savidge
ID: 39847624
What are you hoping to achieve with that?
0
 
LVL 5

Accepted Solution

by:
dannygonzalez09 earned 500 total points
ID: 39847625
give this a try

,BasePrice = Case when BaseStorePrice = 1
                        then CONVERT(VARCHAR(100),BaseStorePrice)
                        else CONVERT(VARCHAR(100),BaseStoreQty) + ' / ' + CONVERT(VARCHAR(100),BaseStorePrice)
End
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 39847629
Paraphrasing the above T-SQL...

CASE
  WHEN BaseStorePrice = 1 THEN {a number }
  ELSE {a varchar} END

CASE blocks with multiple WHEN..THEN..ELSE have to return a value of the same data type, so in this case returning either a numeric 1 or a varchar 'the quantity / the price' won't work.

Try '1' instead of 1 so that both will return a varcahr.
0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 39847636
tks
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This article discusses how to implement server side field validation and display customized error messages to the client.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
The viewer will learn how to dynamically set the form action using jQuery.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question