Html代码不返回SQL Server中的十进制值
问题描述:
我在其中一个存储过程中有以下代码。Html代码不返回SQL Server中的十进制值
SELECT
'<table width=100% style=''FONT-SIZE: 10px; FONT-FAMILY: MS Reference Sans Serif;''><tr><td>' +
'</td><Other Wages</td><td al<td align=center>' +
LTRIM(STR(0.30))+'</td></tr></table>' AS SCHEDSTATS
上述代码的问题是,它不返回小数值。上面的代码的输出来这样,
<table width=100% style='FONT-SIZE: 10px; FONT-FAMILY: MS Reference Sans Serif;'>
<tr>
<td></td><Other Wages</td>
<td al<td align=center>0</td></tr></table>
(我已经给它在输出变得0
0.30
十进制值)。我如何在上面的代码中显示小数值?
感谢您的帮助
答
STR (float_expression [ , length [ , decimal ] ])
float_expression
Is an expression of approximate numeric (float) data type with a decimal point.
长度
Is the total length. This includes decimal point, sign, digits, and spaces. The default is 10.
小数
Is the number of places to the right of the decimal point. decimal must be less than or equal to 16. If decimal is more than 16 then the result is truncated to sixteen places to the right of the decimal point.
代码
SELECT STR(0.30, 3,2);
,如果你不想让你只想
0.30
任何改变不使用STR
使用LTRIM((0.30))
答
你有你的STR语法错误。 语法
STR(编号[,长度[,decimal_places])
,所以你需要提供的STR位小数看到十进制值,否则它会四舍五入。
您可以在下面找到有用的链接:
答
这不是一个HTML的问题。 STR()函数返回一个四舍五入的整数,除非您指定的小数位数大于0.
您必须编写“STR(0.30,5,2)”,表示“返回最多5位数的字符串, 2位小数“。
结果将是正确的。
答
的SQL Server 2008R2
select LTRIM(STR(0.30))
select LTRIM(STR(0.30,8,2))
0.30
哇,你在SP生成的HTML代码?:-O – Oscar
你想要什么? – wiretext
@oscar。在应用程序中似乎是一个非常老的sp,它以HTML格式 – bmsqldev