开发者

SQL Server double to decimal read problem

开发者 https://www.devze.com 2022-12-30 02:08 出处:网络
from front end application I am sending the value as 0.15 to database via a stored procedure, but it gets stored as 0 value. Why? please guide. I am using开发者_如何学JAVA C# + ASP.NET + SQL Server 20

from front end application I am sending the value as 0.15 to database via a stored procedure, but it gets stored as 0 value. Why? please guide. I am using开发者_如何学JAVA C# + ASP.NET + SQL Server 2008


What datatype does the column have that you store it into? Also: what datatype does the parameter of the stored procedure have that you use to pass in that value??

My hunch: if you use e.g. DECIMAL then you're using DECIMAL(18,0) --> up to 18 digits, but none after the decimal point. That would truncate 0.15 to 0. Just using DECIMAL as a data type doesn't automatically make it support after-decimal-point digits (a common mistake a lot of SQL programmers make - once - and then they know it).

Make sure both the parameter of the stored proc and the column in the table allow for fractional values, e.g. are something like DECIMAL(18,4) or something like that


I'm pretty sure somewhere in your code your having an int / integer and this is where it get rounded to 0

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号