Ms Sql Server A Domain Error Occurred
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up A domain error occurred in SQL Server 2000 while updating the data up vote 0 down vote favorite I have created a function like the one below ALTER FUNCTION fn_Calc (@Lat1 Float, @Lng1 Float, @Lat2 Float, @Lng2 Float) RETURNS Float AS BEGIN Declare @x as Float Declare @y as Float Declare @Distance as Float Select @x = (SIN(RADIANS(@Lat1)) * SIN(RADIANS(@Lat2)) + COS(RADIANS(@Lat1)) * COS(RADIANS(@Lat2)) * COS(ABS((RADIANS(@Lng2)) - (RADIANS(@Lng1))))) Select @y = ATAN((SQRT(1-(POWER(@x,2))) / @x)) Select @Distance = (1.852 * 60.0 * ((@y / PI()) * 180)) / 1.609344 RETURN @Distance END I am using the above function to update a column in a table like below: Update test set calc = dbo.fn_Calc(cast(Lat as float), cast(Long as float), dblLat, dblLong) While running the above query I got the error. "A domain error occured." What can be causing this error? sql-server sql-server-2000 share|improve this question edited Apr 22 '13 at 13:29 marc_s 454k938701033 asked Apr 22 '13 at 13:08 Roshan 12610 2 sql-server-performance.com/2007/domain-error-occurred –muhmud Apr 22 '13 at 13:09 Please, specify the parameter values, what you pass into function. –Devart Apr 22 '13 at 13:18 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted Try this one - ALTER FUNCTION dbo.fn_Calc ( @Lat1 FLOAT , @Lng1 FLOAT , @Lat2 FLOAT , @Lng2 FLOAT ) RETURNS FLOAT AS BEGIN DECLARE @x FLOAT , @y FLOAT SELECT @x = SIN(RADIANS(@Lat1)) * SIN(RADIANS(@Lat2)) + COS(RADIANS(@Lat1)) * COS(RADIANS(@Lat2)) * COS(ABS(RADIANS(@Lng2) - RADIANS(@Lng1))) SELECT @y = ATAN(SQRT(ABS(1 - POWER(@x, 2))) / @x) RETURN (111.12 * ((@y / PI()) * 180)) / 1.609344 END share|improve this answer answered Apr 22 '13 at 13:21 Devart 76.7k12100120 Hi Devart, i think its working for me. i need to do some more testing to compare the values. Can you please let me know what could be the reason of getting the error. I Really appreciate your help. Thanks a ton. –Roshan Apr 22 '13 at 13:52 @Roshan your version might attempt to perform a square root on a negative number, which SQL Server can't do (try SELECT S
I am running a query that takes the cross product of a table against itself and uses some trigonometry functions to determine the distance between all the values. The cross product works but when I introduce the trig function only part of the result set comes back. No error is reported only a very non-descriptive message: A domain error occurred. Has anyone ever seen this before? I have not been able to find any information on it web. Here is a query that tes the error I am getting using http://stackoverflow.com/questions/16147911/a-domain-error-occurred-in-sql-server-2000-while-updating-the-data the Northwind database: Select o1.OrderID, o2.OrderID, foo = ACOS( COS(o1.OrderID) ... Thread Tools Show Printable Version Email this Page… Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode August 21st,05:51 PM #1 ??? Domain Error Occurred ??? I am running a query that takes the cross product of a table against itself and uses some trigonometry functions to http://www.justskins.com/forums/domain-error-occurred-302471.html determine the distance between all the values. The cross product works but when I introduce the trig function only part of the result set comes back. No error is reported only a very non-descriptive message: A domain error occurred. Has anyone ever seen this before? I have not been able to find any information on it web. Here is a query that tes the error I am getting using the Northwind database: Select o1.OrderID, o2.OrderID, foo = ACOS( COS(o1.OrderID) * COS(o2.OrderID) + SIN(o1.OrderID) * SIN(o2.OrderID) ) From Orders o1 Cross Join Orders o2 Thanks for taking a look. -Scott Scott Guest August 21st,05:59 PM #2 Re: ??? Domain Error Occurred ??? I get the same thing on 2000 SP3 (760). I'll see what I can do to report it... "Scott Archibald"
SQL Server experts to answer http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=184755 whatever question you can come up with. Our new SQL Server Forums are live! Come on over! We've restricted the ability to create https://www.experts-exchange.com/questions/23247473/A-domain-error-occured-Everything-worked-on-Friday.html new threads on these forums. SQL Server Forums Profile | ActiveTopics | Members | Search | ForumFAQ Register Now and get your question ms sql answered! Username: Password: Save Password Forgot your Password? All Forums SQL Server 2005 Forums Transact-SQL (2005) A domain error occurred in Sql server Reply to Topic Printer Friendly Author Topic roshanrise Starting Member India 1 Posts Posted-04/22/2013: 09:24:42 I have created a function like ms sql server the one belowALTER FUNCTION fn_Calc(@Lat1 Float, @Lng1 Float, @Lat2 Float, @Lng2 Float)RETURNS FloatASBEGINDeclare @x as FloatDeclare @y as FloatDeclare @Distance as FloatSelect @x = (SIN(RADIANS(@Lat1)) * SIN(RADIANS(@Lat2)) + COS(RADIANS(@Lat1)) * COS(RADIANS(@Lat2)) * COS(ABS((RADIANS(@Lng2)) - (RADIANS(@Lng1)))))Select @y = ATAN((SQRT(1-(POWER(@x,2))) / @x))Select @Distance = (1.852 * 60.0 * ((@y / PI()) * 180)) / 1.609344RETURN @DistanceENDI am using the above function to update a column in a table like below:Update test set calc = dbo.fn_Calc( cast(Lat as float), cast(Long as float), dblLat, dblLong) While running the above query I got the error."A domain error occured."What can be causing this error?Thanks,Roshan. NThanks,Roshan.N Edited by - roshanrise on 04/22/2013 09:25:33 bandi Flowing Fount of Yak Knowledge India 2242 Posts Posted-04/22/2013: 09:42:48 Check this link http://books.google.co.in/books?id=bTIq5XpJgTkC&pg=PA106&lpg=PA106&dq=%22A+domain+error+occurred.%22+in+sql+server&source=bl&ots=d1WfCcx8DQ&sig=gARctqqHx6V1ywHaaBhNIsS0SVg&hl=en&sa=X&ei=fz11UdqWLsTorQew5IGICA&ved=0CIgBEOgBMAk#v=onepage&q=%22A%20domain%20error%20occurred.%22%20in%20sql%20server&f=falseSome trigonometric or LOG functions can throw domain error in the case of NULL values... http://st
for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Ask a Question Ask for Help Receive Real-Time Help Create a Freelance Project Hire for a Full Time Job Ways to Get Help Expand Search Submit Close Search Login Join Today Products BackProducts Gigs Live Careers Vendor Services Groups Website Testing Store Headlines Experts Exchange > Questions > A domain error occured?? Everything worked on Friday? Want to Advertise Here? Solved A domain error occured?? Everything worked on Friday? Posted on 2008-03-17 MS SQL Server 2005 2 Verified Solutions 4 Comments 2,564 Views Last Modified: 2012-05-05 Hello All, So, I have a stored procedure that is pretty simple. Everything worked great on Friday. I was starting to build reports based on the data that this sp is providing. I get into work today and when I run the sp I get the following error: Msg 3623, Level 16, State 1, Line 23 A domain error occurred. If I double click on it, it takes me to the following section of code: INSERT INTO @TmpCellMonthlyROR_By_Domicle SELECT ((dateadd(yy, (year(Date)-1900), 0)) + (dateadd(mm, (month(Date)-1), 0))), CellID, InvProdName, Domicile, (Exp(Sum(Log(ROR+1)))-1) FROM @TmpDailyPL_By_Domicile GROUP BY ((dateadd(yy, (year(Date)-1900), 0)) + (dateadd(mm, (month(Date)-1), 0))), CellID, InvProdName, Domicile ORDER BY CellID What has happened that would cause this. I haven't changed anything from Friday to today?? I have attached all of the code for the sp. Please any help would be greatly appreciated. DomicileCode.txt 0 Question by:ltmnm Facebook Twitter LinkedIn Google LVL 60 Best Solution bychapmandew Typically domain errors occur because a certain data value breaks a constraint. Did you check your data to see if anything is funky in it that your table doesn't expect? Go to Solution 4 Comments LVL 60 Overall: Level 60 MS SQL Server 2005 47 Message Accepted Solution by:chapmandew2008-03-17 Typically domain errors occur because a certain data value breaks a constraint. Did you check your data to see if anything is funky in it that your table doesn't expect? 0 LVL 27 Overall: Level 27 MS SQL Server 2005 16 Message Assisted Solution by:ptjcb2008-03-17 Check the values in this line: (Exp(Sum(Log(ROR+1)))-1) and verify that the values are correct. Look at the data first (as chapmandew said) before you start redoing the code. http://www.sql-server-performance.com/faq/domain_error_occurred_p1.aspx 0 LVL 1 Overall: Level 1 MS SQL Server 2005 1 Message Author Comment by:ltmnm2008-03-17 Yes, I did find the error occurring in the Log() section. I traced it back to the exact row of data in the table