我有一个设置为money的sql列,它在小数点后面有四个数字。我在更新查询中计算此列,我想整理此列。例如:2388.6796,应该是2389
Math.Ceiling(0.5);
SqlCommand cmd1 = new SqlCommand("UPDATE Products SET [ThirdPartyRate] = 'Ceiling(" + GridView1.Rows[SelectedIndex].Cells[6].Text.ToString() + "' * [Price]) WHERE [Supplier] like '" + GridView1.Rows[SelectedIndex].Cells[0].Text.ToString() + "' ", con);
答案 0 :(得分:1)
使用:
CEILING ( numeric_expression )
原则上你可以这样做:UPDATE TABLE Products SET rounded_val=CEILING(not_rounded_val);
SqlCommand cmd1 = new SqlCommand("UPDATE Products SET [ThirdPartyRate] = CEILING(" +
GridView1.Rows[SelectedIndex].Cells[6].Text.ToString() +
" * [Price]) WHERE [Supplier] like '" +
GridView1.Rows[SelectedIndex].Cells[0].Text.ToString() + "' ", con);