Create a custom function ( MSDN link ) and minimize the code:
CREATE FUNCTION [dbo].[RemoveTrailingZeros]
(
@Value decimal
)
RETURNS decimal
AS
BEGIN
RETURN replace(rtrim(replace(@Value, '0', ' ')), ' ', '0')
END
You would use it as follows:
SELECT dbo.RemoveTrailingZeros(12.456400000)
source
share