Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Most likely you are expecting boolean short circuit to rescue the order of evaluating your WHERE clause. This is a known fallacy: boolean operator short circuit is not guaranteed in SQL. See <a href="http://rusanu.com/2009/09/13/on-sql-server-boolean-operator-short-circuit/" rel="nofollow">On SQL Server boolean operator short-circuit</a> for a discussion and proof that boolean short circuit can be skipped by query optimizer. Similar topic is <a href="http://rusanu.com/2011/08/10/t-sql-functions-do-no-imply-a-certain-order-of-execution/" rel="nofollow">T-SQL functions do no imply a certain order of execution</a>. The gist of it is that SQL is a <em>declarative</em> language, not an imperative one.</p> <p>In your case probably your cast and converts will be called for properties with IDs <strong>different from <code>property_id = 9165</code> and <code>property_active=1</code></strong> and may attempt to cast string values that are not numerics to a numeric, hence the exception you see. Is difficult to give a precise diagnosis since so much information is missing from your problem description (like the <em>exact</em> definition of all object involved, including all tables, indexes, column types etc). </p> <p>Your best avenue is to upgrade to SQL Server 2008 and use the built in <a href="http://msdn.microsoft.com/en-us/library/cc280766.aspx" rel="nofollow">geography</a> type which has built-in support for <a href="http://msdn.microsoft.com/en-us/library/bb933808" rel="nofollow"><code>STDistance</code></a>:</p> <blockquote> <p>This is a close approximate to the geodesic distance. The deviation of STDistance() on common earth models from the exact geodesic distance is no more than .25%.</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload