title: SQL Server Stored Procedure - Syntax Error
body: <p>I am trying to create a stored procedure that returns all rows that are within a given lat/lng and search radius.</p>
  
  <p>When I execute the create code (below) I get: </p>
  
  <p>"Incorrect syntax near '&lt;'"</p>
  
  <p>It must be this line:</p>
  
  <pre><code>@p1.STDistance(geography::Point([LATITUDE], [LONGITUDE], 4326)) &lt;= @searchRadius as [DistanceInKilometers]
  </code></pre>
  
  <p>Any ideas why?</p>
  
  <p>Thanks</p>
  
  <p>Here is the entire SPROC:</p>
  
  <pre><code>SET ANSI_NULLS ON
  GO
  SET QUOTED_IDENTIFIER ON
  GO
  -- =============================================
  -- Author:         slinky66
  -- Create date:    2013-06-26
  -- Description:    Returns all meeting locations within a given lat/lng and search radius
  -- =============================================
  CREATE PROCEDURE [dbo].[kiwone_GetNearMeetingLocationInKilometers_SP] 
  
      -- Add the parameters for the stored procedure here
      @latitude decimal(18,14),
      @longtitude decimal(18,14),
      @searchRadius decimal (3,2),
      @p1 geography
  AS
  
  BEGIN
  
      SET NOCOUNT ON;
  
     -- @p1 is the point you want to calculate the distance from which is passed as parameters
     -- declare @p1 geography = geography::Point(@latitude,@longtitude, 4326);
  
     select
     c.LABEL_NAME,
     k.*,
     @p1.STDistance(geography::Point([LATITUDE], [LONGITUDE], 4326)) &lt;= @searchRadius as [DistanceInKilometers]
     from [USR_KIW_CUS_MEETING] as k
     join CUSTOMER as c
     on c.MASTER_CUSTOMER_ID = k.MASTER_CUSTOMER_ID
     where c.USR_MEMBERSHIP_STATUS_CODE NOT IN('CR','CSD')
  END
  GO
  </code></pre>