Working with some good ole Sql today, get slapped in the face with this
Msg 3623, Level 16, State 1, Procedure FindLocations, Line 9
A domain error occurred.
Gah! Considering I copied this from an in-line sql statement, I figured I was golden, wrong. So what's going on? The procedure that did this is doing a little calculation to determine miles away based on a lat/long value lookup. Where's the problem? Lat/Long values can be negative and if you know anything about math, the square root of a negative number is (!) imaginary, something sql has NO CLUE how to handle (but matlab does!).
So, to fix this problem, and since no results will ever be negative miles away (relativity?), I pulled the calculation result into the magical "ABS" (absolute) function to give me a positive number, no matter what.