I am working on an order management web project in C# which can be provided to multiple clients.
In 'orders' table, I have a field 'Qty' of 4 decimals. Now not all clients may require 4 decimal places, so I have a table 'Config' which holds this value in field 'QtyDecimal'.
Presently what I am doing to show the correct number of decimals is something like this:
string xQtyDec = getQtyDecimalFromConfig();
sqlCommand = "Select CAST(Qty as numeric(18," + xQtyDec + ")) [Quantity] from orders";
...
I was wondering if this could be accomplished in SQL itself, something like
SELECT CAST(Qty as numeric(18, (SELECT QtyDecimal FROM config))) [Quantity] from orders
Is this possible?