Solved

sql with qty slash price

Posted on 2014-02-10
4
291 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
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 65

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how the fundamental information of how to create a table.

809 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