Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Order of precedence in where clause

$
0
0

Im getting an error on this statement:

SELECT *

FROM

[My Table]

WHERE

ISDATE([DATE OF BIRTH])= 1

AND

CONVERT(DATETIME, [DATE OF BIRTH], 101)<'01/01/1899'

Because its evaluating the second condition first and running into non dates.  Is there a way to change this where clause to guarantee it will exclude the non-dates? Also, because of the way the app was written with dynamic SQL, it has to be done in the where clause.

the error is :

The conversion of a nvarchar data type to a datetime data type resulted in an out-of-range value.


John Schroeder




Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>