andrew4582

fx_GetAirportsNearLatLong SQL Function

Oct 30th, 2011
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1.  
  2.  
  3. /****** Object:  UserDefinedFunction [dbo].[fx_GetAirportsNearLatLong]    Script Date: 10/30/2011 11:28:08 ******/
  4. IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[fx_GetAirportsNearLatLong]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
  5. DROP FUNCTION [dbo].[fx_GetAirportsNearLatLong]
  6. GO
  7.  
  8. USE [PSDB]
  9. GO
  10.  
  11. /****** Object:  UserDefinedFunction [dbo].[fx_GetAirportsNearLatLong]    Script Date: 10/30/2011 11:28:08 ******/
  12. SET ANSI_NULLS ON
  13. GO
  14.  
  15. SET QUOTED_IDENTIFIER ON
  16. GO
  17.  
  18. CREATE FUNCTION [dbo].[fx_GetAirportsNearLatLong](@A float,@B float, @Distance int)  
  19. RETURNS table AS  
  20. RETURN
  21.   (SELECT *
  22.    FROM   (SELECT ID,
  23.                   NAME,
  24.                   ICAO,
  25.                   dbo.Getlatlongdistance(@A, @B, WGS_DLAT, WGS_DLONG) AS
  26.                   Distance
  27.            FROM   dbo.Airport) AS x
  28.    WHERE  x.Distance < @Distance)  
  29.  
  30.  
  31.  
  32. GO
Advertisement
Add Comment
Please, Sign In to add comment