SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE FUNCTION [dbo].[to_int] (@d varchar(255))
RETURNS integer
with execute as CALLER
    AS
    BEGIN
		declare @to_int integer;
		set @d = replace(@d, '"', '');
		if @d = ''
			return 0
		if isnumeric(@d) <> 1
			return 0
		set @to_int = convert(integer, @d);
			
		return (@to_int);
    END
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
