BAQ - data type NVARCHAR to include integers and text


(Himal Gurung) #1

Hi all,

I have a simple calculated field that would display numbers separated by commas.
I am expecting to get values separated by commas like this:
3, 5, 6

When I enter the following,
cast(round(PurHistory.Calculated_MinOrderQty,0) as int) + convert(varchar, ', ') +
cast(round(PurHistory.Calculated_AvgOrderQty,0) as int) + convert(varchar, ', ') +
cast(round(PurHistory.Calculated_MaxOrderQty,0) as int)

I get an error message saying:
Text: Conversion failed when converting the varchar value ’ ,’ to data type int.

How do I rewrite it so that the comma is also included?


(Daryl Hewison) #2

I think you’ll need to convert your cast ints to varchar or nvarchar before “+” will join them as strings instead of trying to add them up.

(Himal Gurung) #3

thanks ! that did it.
i was focusing on removing decimals and removed the conversion i previously had.