zip code database

  • got the (all the zip codes with in a given radius )and it is right on the money.. i am stil working on the distance between.... but the new one that i added in the folder is perfect for finding all the zip codes with in a given radius..

    i have also added another zip database that is alot better....

    and newer

    http://afcc1.com/Zips_With_Sprocs.zip

     

    =================================================================

    SET QUOTED_IDENTIFIER ON

    GO

    SET ANSI_NULLS ON

    GO

    ALTER     PROC ZipCode_FindZipCodesWithinRadius

    (

      @ZipCode Numeric(5, 0) = Null,

      @Miles Float

    &nbsp

    As

     set nocount on

     

     Declare @Latitude Float(10)

     Declare @Longitude Float(10)

     -- Lookup longitude, latitude for zip codes

     Select @Latitude = CONVERT(FLOAT,Latitude), @Longitude = CONVERT(FLOAT,Longitude) From Zips Where Zip = @ZipCode

     

     Select

      TOP 5 Zip, StateCD,

    --

      Avg(3958.75 * ACos(Sin(@Latitude/57.2958) *

      Sin(CONVERT(FLOAT,Latitude)/57.2958) +

      Cos(@Latitude/57.2958) *

      Cos(CONVERT(FLOAT,Latitude)/57.2958) *

      Cos(CONVERT(FLOAT,Longitude)/57.2958 - @Longitude/57.2958))) As Miles

     From

      Zips

     Where

      CONVERT(FLOAT,Longitude) Is Not Null

      And CONVERT(FLOAT,Latitude) Is Not Null

      And @Miles >=

       (

       3958.75 * ACos(Sin(@Latitude/57.2958) *

       Sin(CONVERT(FLOAT,Latitude)/57.2958) +

       Cos(@Latitude/57.2958) *

       Cos(CONVERT(FLOAT,Latitude)/57.2958) *

       Cos(CONVERT(FLOAT,Longitude)/57.2958 - @Longitude/57.2958))

       )

      And Zip != @ZipCode

     Group by zip, StateCD

     Order by miles

     return

    GO

    SET QUOTED_IDENTIFIER OFF

    GO

    SET ANSI_NULLS ON

    GO

     

    Dam again!

  • This was removed by the editor as SPAM

  • This was removed by the editor as SPAM

Viewing 3 posts - 31 through 32 (of 32 total)

You must be logged in to reply to this topic. Login to reply