title: SQL 2012 Error in LEFT or SUBSTRING function
body: <p>I am trying to execute the following SQL query:</p>
  <pre><code>SELECT TMP.*,COUNT(*) OVER () AS rCount 
  FROM (
      SELECT venueID, 
             venueName AS venueName, 
             venueSpanish AS spanish, 
             venueAddress + ', ' + venueCity + ', ' + venueState + ' ' + venueZip AS venueAddress, 
             venueLatLong AS coordinates, 
             CONVERT(VARCHAR, venueEventDate, 101) + ' @ ' + CONVERT(VARCHAR,venueTime) AS dateAndTime, 
             SUBSTRING(venueLatLong, 1, CHARINDEX(',', venueLatLong)-1) AS Lat, 
             SUBSTRING(venueLatLong, CHARINDEX(',', venueLatLong) + 1, 1000) AS Lng, 
             (round(3959 * acos (cos(radians('35.0935409')) * 
                  cos(radians(SUBSTRING(venueLatLong, 1, CHARINDEX(',', venueLatLong)-1))) * 
                  cos(radians(SUBSTRING(venueLatLong, CHARINDEX(',', venueLatLong) + 1, 1000)) - 
                  radians('-85.0856761')) + 
                  sin(radians('35.0935409')) * 
                  sin(radians(SUBSTRING(venueLatLong, 1, CHARINDEX(',', venueLatLong)-1)))), 1, 1)) AS distance 
      FROM meetUpMarkers) TMP 
  WHERE distance &lt; 30 
  </code></pre>
  <p>However, I am getting this as an error when doing so:</p>
  <blockquote>
  <p>Msg 537, Level 16, State 2, Line 1</p>
  <p>Invalid length parameter passed to the LEFT or SUBSTRING function.</p>
  </blockquote>
  <p>Any help would be great to solve this issue!</p>