A Domain Error Occurred. Mssql
Contents |
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 sybase domain error occurred About Us Learn more about Stack Overflow the company Business Learn more
An Error Occurred During Decryption Sql Server 2008
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss
Ms Sql Ole Db Error Occured Code 80040e14h
Join the Stack Overflow Community Stack Overflow is a community of 4.7 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 450k918621027 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(
up Recent PostsRecent Posts Popular TopicsPopular Topics Home Search Members Calendar Who's On Home » SQL Server 2005 » SQL Server 2005 General Discussion » A domain error occurred in Sql server 2005... A domain error occurred in Sql server 2005 while updating the data Rate Topic Display Mode Topic Options Author Message roshan.nc 74309roshan.nc 74309 Posted Monday, April 22, 2013 7:21 AM Grasshopper Group: General Forum Members Last Login: Monday, September 21, 2015 1:05 AM Points: 14, Visits: 47 I have created a function like the one belowCreate FUNCTION fn_Calc(@Lat1 Float, @Lng1 Float, @Lat2 Float, @Lng2 Float)RETURNS FloatASBEGINDeclare @x as FloatDeclare @y as FloatDeclare http://stackoverflow.com/questions/16147911/a-domain-error-occurred-in-sql-server-2000-while-updating-the-data @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 http://www.sqlservercentral.com/Forums/Topic1444977-149-1.aspx causing this error?Thanks,Roshan. N Post #1444977 wolfkilljwolfkillj Posted Tuesday, April 23, 2013 10:26 AM Ten Centuries Group: General Forum Members Last Login: Monday, August 24, 2015 12:20 PM Points: 1,064, Visits: 2,582 I had this problem once before, but I was using a slightly different formula for calculating distances between lat/long pairs. Unfortunately, I no longer work for my employer at the time and don't have the notes I made of this issue to be more specific, so I only vaguely recollect the circumstances. IIRC, I discovered that there were certain input values that would cause the T-SQL COS function to return results just slightly outside the -1 < x < 1 range. This cascaded through the calculation and resulted in an input to the ACOS function that also fell outside the -1 < x < 1 range, which generated the domain error. I corrected the problem by adjusting any results of the COS function that fell outside the range to 1 or -1 as appropriate. The way I finally diagnosed the problem was by running a query that included a column for each individual part of the formula, building up from column to column until I had the whole result. When I ran this query on the dataset that caused the domain error, I narrowed down the query to include only the rows that
SQL Server experts to answer whatever question you can come up with. Our new SQL Server http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=184755 Forums are live! Come on over! We've restricted the ability to https://social.msdn.microsoft.com/Forums/sqlserver/en-US/4702947d-f78b-41f1-b8ef-c217f20ef68a/a-severe-error-occurred-?forum=transactsql create new threads on these forums. SQL Server Forums Profile | ActiveTopics | Members | Search | ForumFAQ Register Now and get your question answered! Username: Password: Save Password Forgot your Password? All Forums SQL Server 2005 Forums Transact-SQL (2005) A domain error occurred in Sql error occurred 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 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)) domain error occurred - (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://stackoverflow.com/questions/1564405/how-to-fix-domain-error-in-sql-server-2005-when-using-log-function-to-get-pr--Chandu Edited by - bandi on 04/22/2013 09:51:23 russell Pyro-ma-ni-yak USA 5072 Posts Posted-04/22/2013: 14:26:48 Make sure there are no divide by zero happening too Topic Reply to Topic Printer Friendly Jump To: Select Forum General SQL Server Forums New to SQL Server Programming New to SQL Server Administration Script Library Data Corruption Issues Database Design and Application Architecture SQL Server 20
(Русский)ישראל (עברית)المملكة العربية السعودية (العربية)ไทย (ไทย)대한민국 (한국어)中华人民共和国 (中文)台灣 (中文)日本 (日本語) HomeLibraryLearnDownloadsTroubleshootingCommunityForums Ask a question Quick access Forums home Browse forums users FAQ Search related threads Remove From My Forums Answered by: A severe error occurred !! SQL Server > Transact-SQL Question 0 Sign in to vote EverytimeI run this queryI get severe error message on sql... Anyone know how I can resolve this... I think it may be where im using the POWER function, but not 100% sure cast(round((175*POWER((((CONVERT(float,result)-24.55)/0.854)*0.011312),-1.154))*POWER((CONVERT(float,DATEDIFF(d, [DOB], [test_start_time])/365)),-0.203),0) as int) AS [result] Warning: A domain error occurred. Msg 0, Level 11, State 0, Line 0 A severe error occurred on the current command. The results, if any, should be discarded. Tuesday, January 18, 2011 4:07 PM Reply | Quote Answers 0 Sign in to vote Check the previous thread on this topic. Basically, you need to ensure your argument for the power function is greater than 0. You can put it in the ABS function.Premature optimization is the root of all evil in programming. (c) by Donald Knuth Naomi Nosonovsky, Sr. Programmer-Analyst My blog Marked as answer by KJian_ Tuesday, January 25, 2011 8:25 AM Tuesday, January 18, 2011 4:11 PM Reply | Quote Moderator 0 Sign in to vote In addition to what Naom said, it looks like your database is in compatibility mode 80. Not that it will prevent the domain error from appearing, but it might be better handled, without the "severe error" at the end. (Which is an internal error in SQL Server or the client API.) I don't think using ABS in power is a good idea, because power(-1, 0.5) is something very different from power(1, 0.5). Rather you should use CASE: CASE WHEN convert(float, result) - 24.55 >= 0 THEN convert(float, result) - 24.55 END So that you get NULL for negative values. Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se Links for SQL Server Books Online: SQL 2008, SQL 2005 and SQL 2000. (Just click the link you need.) Marked as answer by KJian_ Tuesday, January 25, 2011 8:25 AM Tuesday, January 18, 2011 10:57 PM Reply | Quote All replies 0 Sign in to vote Check the previous thread on this top