SQL Domain Error Occurred? Hu?

by Jesse 6. June 2008 09:57

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.

 

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags: ,

Tech | Weird | Sql

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Like the description says, at my core, I'm a scientist and engineer.  I came from humble beginnings on a 486DX2 Packard Hell playing doom2 on IPX to in a small time retail shop and got into hardware (ISO layers FTW!) and it was all downhill from there.  I'm infinitely curious about almost everything and always wanting to know.

Some of the stuff I'm currently into/researching...

Sitefinity

Ninject

Subsonic

Java

Currently working on ...
i did the hundred 
and some extra stuff

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's, their brother nor their dog's view in anyway.  At all.  Ever.

© Copyright 2007-2008