SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO CREATE FUNCTION [dbo].[to_decimal] (@d varchar(255)) RETURNS decimal(28,8) with execute as CALLER AS BEGIN declare @to_decimal decimal(28,8); if @d is null return 0.0; set @d = replace(@d, '"', ''); if @d = '' return 0.0 set @d = replace(@d, ',', '.'); if isnumeric(@d) = 0 return 0.0 set @to_decimal = convert(decimal(28,8), convert(float, @d)); return (@to_decimal); END GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS OFF GO GO