sql server 2005 - Error with CAST SQL -


i trying combine 2 expressions , display them header. displaying them header isn't problem, combining 2 lines what's holding me back.

i using expression:

cast(max((@purchasecost + @prod_costlbs) * @inputweight) decimal (10,4)) + space(10) +    cast(@inputweight - sum(sum([ic_productlots].[originalquantity_stk])) on () decimal (10,4)) 

i tried using int numericand float well. 1 didn't return error float messed numbers.

i trying output this

cost: $10,000                                     shrink: 120 

whether use or don't use cast error:

error converting data type varchar numeric. 

i can provide full code if needed.

i using microsoft sql server 2005.

you try concatenate numeric , string:

this numeric:

cast(max((@purchasecost + @prod_costlbs) * @inputweight) decimal (10,4)) + 

this string: show official documentation of space function

space(10) + 

this numeric:

cast(@inputweight - sum(sum([ic_productlots].[originalquantity_stk])) on () decimal (10,4)) 

if want use string please cast using varchar instead of decimal(10,4)

in way:

cast(max((@purchasecost + @prod_costlbs) * @inputweight) varchar) + space(10) + cast(@inputweight - sum(sum([ic_productlots].[originalquantity_stk])) on () varchar (10,4)) 

Comments