vendredi 17 juillet 2015

Error with CAST SQL

I am trying to combine two expressions and display them as a header. Displaying them as a header isn't the problem, combining the two lines is what's holding me back.

I am using the expression:

CAST(Max((@PurchaseCost + @Prod_CostLBS) * @InputWeight) AS DECIMAL (10,4)) + SPACE(10) +
   CAST(@InputWeight - SUM(Sum([IC_ProductLots].[OriginalQuantity_Stk])) OVER () AS DECIMAL (10,4))

I tried using INT NUMERICand FLOAT as well. The only one that didn't return an error was float but that messed up the numbers.

I am trying to get an output like this

Cost: $10,000                                     Shrink: 120

Whether I use or don't use CAST I get the error:

Error converting data type varchar to numeric.

I can provide my full code if needed.

I am using Microsoft SQL Server 2005.

Aucun commentaire:

Enregistrer un commentaire