Overall question:
I have a table in my SQL Server with 3 columns (ID, Value, Decimal).
So what I want to do in theory is SELECT the column Value and it should be formatted to the number of decimals specified in that same row.
What I've tried:
SELECT CONVERT(Decimal(18,s.Decimal), s.Value ) FROM Table s
and similar queries with CAST and FORMAT
What I want:
Table:
ID Value Decimal
1 500.754254 2
When I run the query it must return Value as '500.75'
Extra info: I am displaying the result in a WPF (C#) datagrid, and if it will be easier to format there, I don't mind. I just don't know how to.
Value?500.756and you get it rounded as500.76? I suggest to use a string type and store the part before the dot and the part behind in two different columns. Combine them only for your output...decimal(18, 6)? Since it is for display purposes you could use theformatfunction in SQL server or format it in the application.