declare @decimal_val float, @divisor int, @decimal_char varchar(30), @int_val int, @after_decimal_char_val varchar(30), @dot_index int select @decimal_val = 12.6, @divisor = 5, @decimal_char = convert(varchar, @decimal_val), @dot_index = charindex('.', @decimal_char), @int_val = convert(int, substring(@decimal_char, 1, @dot_index - 1)), @after_decimal_char_val = substring(@decimal_char, @dot_index + 1, len(@decimal_char) - @dot_index) select Convert(varchar, (@int_val % @divisor)) + '.' + @after_decimal_char_val
go declare @decimal_val decimal(3, 1) SELECT @DECIMAL_VAL = 12.6 select WHOLE_VAL = convert(int,substring(convert(varchar,@decimal_val), 1, charindex('.', convert(VARCHAR,@decimal_val))-1)), FRAC_VAL = @decimal_val -convert(int,substring(convert(varchar,@decimal_val), 1, charindex('.', convert(VARCHAR,@decimal_val))-1)) |