sql with qty slash price

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

Seven priceFull StackAsked:
Who is Participating?
dannygonzalez09Connect With a Mentor Commented:
give this a try

,BasePrice = Case when BaseStorePrice = 1
                        then CONVERT(VARCHAR(100),BaseStorePrice)
                        else CONVERT(VARCHAR(100),BaseStoreQty) + ' / ' + CONVERT(VARCHAR(100),BaseStorePrice)
Lee SavidgeCommented:
What are you hoping to achieve with that?
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Paraphrasing the above T-SQL...

  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.
Seven priceFull StackAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.