Decimal data Type Display scale part as zero
I have Decimal field in SQLserver 2005 table,
Price decimal(18, 4)
if I write 12 it will be converted to 12.0000, if I write 12.33 it will be converted into 12.3300. Alway开发者_C百科s it's putting zero to the right of the decimal point in the count of Scale Part(4).
I was using these in SQL Server 2000, it was not behaving like this, in SQL Server 2000 if I put 12.5 it will be stored as 12.5 not as 12.5000 what SQLServer2005 do.
My Question is how to stop SQL Server 2005 from putting zeros to the right of the decimal point?
SQL Server 2000 also have stored the value to to 4 decimal places too with trailing zeros.
What you are seeing is how the client tools present it.
decimal (18,4) behaves the same in both versions... otherwise it would be float/real
Edit, after comment:
The data type passed to your client code is always decimal and behaviour will not change. Whether you have format strings or not does not matter to the SQL data type. The behaviour of the data type is unchanged between versions.
I'm only saying the the SQL client tools show the value differently.
If your application displays differently then the data types are different: it is as simple as that.
精彩评论