jteixeira Posted April 30, 2007 Share Posted April 30, 2007 hi, I'm working with microsoft sql Server Express and i would like to know how i turn 151,1500 into 151,15 Link to comment Share on other sites More sharing options...
pulpfiction Posted April 30, 2007 Share Posted April 30, 2007 Are you sure you wanna do that, cos it will change the value of the number. anyways here's way to remove the trailing zeros in decimal number by checking if its a zero or not. so a small modification to this can help your case...http://database.ittoolbox.com/documents/po...rchar-data-2578 Link to comment Share on other sites More sharing options...
nibe49 Posted May 1, 2007 Share Posted May 1, 2007 HiI presume that you are using the comma as a decimal separator and that is what your version of sql server uses.A numeric field when selected doesn't normally return trailing zeros, so this field must be varchar.The following works for me, but I'm not using a comma in the numberdeclare @xa varchar(30);set @xa = '151.1500';print (@xa); -- prints 151.1500 print cast(@xa as float); -- prints 151.15print cast(cast(@xa as float) as varchar); -- prints 151.15Is that any use?nibe Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.