to_int.sql 407 B

1234567891011121314151617181920212223242526
  1. SET QUOTED_IDENTIFIER ON
  2. GO
  3. SET ANSI_NULLS ON
  4. GO
  5. CREATE FUNCTION [dbo].[to_int] (@d varchar(255))
  6. RETURNS integer
  7. with execute as CALLER
  8. AS
  9. BEGIN
  10. declare @to_int integer;
  11. set @d = replace(@d, '"', '');
  12. if @d = ''
  13. return 0
  14. if isnumeric(@d) <> 1
  15. return 0
  16. set @to_int = convert(integer, @d);
  17. return (@to_int);
  18. END
  19. GO
  20. SET QUOTED_IDENTIFIER OFF
  21. GO
  22. SET ANSI_NULLS OFF
  23. GO
  24. GO