Divide By Zero Error Trapping

Jul 20, 2005

I have the following line in a select statement which comes up with a
divide by zero error.

CAST(CASE Splinter_Status
WHEN 'SUR' THEN 0
ELSE CASE WHEN Sacrifice>=1
THEN 3*m.Premium/100-(m.Sacrifice * 3*m.Premium/100)/
(m.Gross+m.Sacrifice)
ELSE 0
END
END AS Float)AS Bond2,

The error happens on the section (m.Gross + m.Sacrifice) as this can
equal zero and throws out the part of the calc that divides by it. It
is correct in some instances that it does so. The full SQL statement
has a large number of these expressions so I need a method I can apply
to any line if possible.

I know that it is mathmatically correct to error where this value is
zero, but what I want to do is set the output of the entire expression
to zero if there is an error.

Realistically an error such as this could happen at a few points in
the expression (or one of many others), so I need to find a way of
catching any error in the expression and setting the return value to
0. I thought of using a CASE statement, but wondered if there was a
better way of looking at this as the case statement would have to
check each variation where it could throw an error.

Any ideas ?

Thanks

Ryan

View 3 Replies


ADVERTISEMENT

Trapping BCP Error From SP

Jul 20, 2005

HII am using the following code in an SP, it seems like an ugly hack Ihave done to check if the BCP was working or not, I check the table itshold have filled instead of checking the error from BCP itself.Does anyone know how I can check the BCP errors directly?this is the code I am using.--------------------------------------create procedure q_spr_autoinventeringAScreate table ##q_tbl_autoinventering (ean13 varchar(13),antal decimal,signatur varchar(10),lagstalle int)exec master..xp_cmdshell"bcp ##q_tbl_autoinventering inc:outpathhd1invent.txt -t ; -Usa -P13hla -c -C "declare@invjournal int,@lagstalle int,@invdatum datetime,@ean13 varchar(15),@antal decimal,@artnr varchar(50),@lagplats varchar(20),@lagsaldo decimal,@mysubject nvarchar(4000)IF EXISTS (select * from ##q_tbl_autoinventering)begin-----------------------------------------------it seems so ugly to check the table instead of the BCP error itself soany pointers would be gladly appreciated, I tried to check @@error butthat did not seem to worked how I needed it.in short what I want is thisif bcp did not work break out of the SP and wait until called nexttime by sql server agent. and by not working I only mean that therewas no file to fetch, if there is a file to fetch and the table iscreated I have lots of checks in the SP to make sure the values arecorrectrgdsMatt

View 1 Replies View Related

Trapping SQL UpDate Error In VWD

Apr 27, 2007

Hi:I am trying to update a UserInfo record using a stored procedure.  It uses a uniqueidentifier UserId as the primary key.  I keep getting an error and am trying to trip it using try-catch statements in both SQL Server Express and VWD 2005.My challenge is that I cannot enter a sample UserId to test the query in SQL Server because it sees my unique identifier as a string and I cannot get the error back to VWD to see where the problem is.  The stored procedure looks something like:ALTER PROCEDURE [dbo].[UpDateUserInfo]    @Userid uniqueidentifier,    @FirstName nvarchar(50),    @LastName nvarchar(70),    @WorkPhone nvarchar(50),ASBEGIN TRY    SET NOCOUNT OFF;        UPDATE Members    SET FirstName = @FirstName,     LastName = @LastName,    WorkPhone = @WorkPhone,    CellPhone = @CellPhone    WHERE UserID = @Userid;END TRYBEGIN CATCH  EXECUTE usp_GetErrorInfo;END CATCH;  CREATE PROCEDURE [dbo].[usp_GetErrorInfo]AS    SELECT        ERROR_NUMBER() AS ErrorNumber,        ERROR_SEVERITY() AS ErrorSeverity,        ERROR_STATE() AS ErrorState,        ERROR_PROCEDURE() AS ErrorProcedure,        ERROR_LINE() AS ErrorLine,        ERROR_MESSAGE() AS ErrorMessage; When I put in the value d2dbf5-409d-4ef4-9d35-0a938f6ac608 which is an actual UserId in SQL server when I execute, the program tells me there incorrect syntax.   So I would greatly appreciate it if somebody could help me with the following two questions: 1.  How do I input a uniqueidentifier when executing a query in SQL Server Express?2.  How can I get any errors that I trap (I think I have the right set up here) to show up back in my ASP.Net application? Any help greatly appreciate.Roger Swetnam 

View 5 Replies View Related

Error Trapping In StoredProcedure

Feb 4, 2003

I have a DTS package (AdIns) that inserts to an administrative table. The Administrative table utilizes the "with ignore_dup_key" option on the index. There are other admin jobs in the DTS that are based on the return code of a parent package.

The "3604:duplicate key ignored" is an expected result of the parent package, yet it sends an failure return code to the dependent (AdIns) package, causing erroneous entries to the final audit table.

How can I reset the return code from the parent package?

TIA!:mad:

View 1 Replies View Related

Trapping Error Messages

Jul 20, 2005

Hi everybody,I need to trap error messages in my stored procedures and log them. I canuse @@ERROR global variable to get the error code and look it up insysmessages table to get the description. Then using xp_logevent I log theerror.The problem is this description needs to be formatted. For example if I tryto insert NULL into a column which is not nullable, I'll get error #515. Thedescription of error #515 in sysmessages is:Cannot insert the value NULL into column '%.*ls', table '%.*ls'; columndoes not allow nulls. %ls fails.Is there a way to get the formatted message? What is the best approach totrap errors, filter them, add some additional information to the message andsend it to server's event logger?TIA,Shervin

View 6 Replies View Related

Error Trapping Of Datasource Control

Oct 1, 2007

Hello,
I encountered an interesting situation. I have a gridview and a sqldatasource. It has delete function. When I delete a record an error of foreign key violation is raised. I would like to trap this error and give a user friendly message to the user.
If I use ADO.Net I can use Try/Catch, but it seems there is no way to do the same thing using datasource. Anyone knows?
Thank you,
J

View 6 Replies View Related

Trapping Package Validation Error

Aug 9, 2006

Hello,



I created a new SSIS Package. I want to send an e-mail when an error occurrs.



I set the OnError event to send an e-mail. I then decided to test this so I dropped my input SQL table. When I drop the import SQL table I get a Package Validation Error and I don't get my e-mail.



Am I making a mistake. I want to always send an e-mail when an error occurrs in my SSIS package.

By the way I did add an e-mail at the end of my SSIS package to verify my SMTP is working - it did.



Thanks,



Michael

View 3 Replies View Related

ForEach Trapping An Error And Continuing

Aug 3, 2006

I have a ForEach loop that processes a list of databases. Inside the loop I many steps, one of which is a sequence that contains two steps. Either of these steps may fail (they are attempting to start mirroring and could fail for any number of reasons). I would like to trap this error and ignore it so the For loop will continue, but still fail if other steps than this one fail. The only thing I've been able to do so far is to tell the whole loop to continue through some insane number of errors. Is there a way to identify or actually ignore the error? In the sequence I have have on completion and from the sequence to the next step (which checks if mirroring actually started) is running on completion.



Thanks.

View 2 Replies View Related

SQL Error Trapping Using @@Error Without ABORTING....

Oct 9, 2001

I am trying to cycle a bunch of tables (actually doing my own refresh from another database); if one in the middle of the list fails, the whole script fails. My question is, how does one do an "ON ERROR" statement in SQL. Even though I preserve the error code using:
set @RetCode=@@ERROR, I never get the chance to ask (IF @retCode <> 0)
and then try to case on it, it seems the system wants no part of it and exits while printing the SQL system error (which is usally the dreaded deadlock and I 've been selected).

Any help would be greatly appreciated!

Thanks!

View 1 Replies View Related

Integration Services :: SSIS And Trapping (Duplicate Primary Key) Import Error

Oct 13, 2015

I want to import a data file into a sql table. The table has a primary key but the data could have a duplicate value in the PK column (error in the source data). How can I "trap" for this type of error in SSIS?

View 10 Replies View Related

Divide By Zero Error

Feb 24, 2006

Hello,

When I execute the following query, I get a Divide by zero error. I believe the Divide By zero error is occuring in the following statement. How do I avoid the error?


ModelDiff = CONVERT(decimal (8, 4), abs(yest.ModelValue-today.ModelValue)/abs(yest.ModelValue))


drop table #MaxArchiveDates
DECLARE @MaxArchiveDate INTEGER
, @EdgeModelID INTEGER
, @DefinitionID INTEGER
SELECT ArchiveDataDate = MAX(ArchiveDataDate) INTO #MaxArchiveDates FROM intldbArchive.dbo.GOModelUniversesSaveD
UNION SELECT ArchiveDataDate = MAX(ArchiveDataDate) FROM intldbArchive.dbo.GOSecurityGroupModelValSaveD
UNION SELECT ArchiveDataDate = MAX(ArchiveDataDate) FROM intldbArchive.dbo.GOSecuritiesSaveD
UNION SELECT ArchiveDataDate = MAX(ArchiveDataDate) FROM intldbArchive.dbo.GOUniverseSecurityMembeSaveD
SELECT @MaxArchiveDate = MIN(ArchiveDataDate) FROM #MaxArchiveDates
SELECT @MaxArchiveDate
SELECT ModelID = today.ModelID
, RelativeUniverseID = today.RelativeUniverseID
, SecurityID = today.SecurityID
, ModelValueT = CONVERT(decimal (8, 4), today.ModelValue)
, ModelValueY = CONVERT(decimal (8, 4), yest.ModelValue)
, ModelDiff = CONVERT(decimal (8, 4), abs(yest.ModelValue-today.ModelValue)/abs(yest.ModelValue))
FROM OptMod.dbo.GO_SecurityGroupModelValues today
JOIN intldbArchive.dbo.GOSecurityGroupModelValSaveD yest
ON today.SecurityID = yest.SecurityID
AND today.ModelID = yest.ModelID
AND yest.ArchiveDataDate = @MaxArchiveDate

Thanks in advance!!!
sqlnovice123

View 1 Replies View Related

Divide By Zero Error

Feb 28, 2006

I am writing a report that deals with time in seconds. I am trying to figure out the average handle time for each call.
To Get this number i use 5 fields. the formula is

(((cs_acd_trk_t + cs_acd_ext_c)/(cs_acd_trk_c + cs_acd_ext_c)) + ((cs_t_acd_wrk)/(cs_acd_trk_c + cs_acd_ext_c))/(cs_acd_trk_c + cs_acd_ext_c))

Which translates to ((Incoming Handle Time) + (Work))/(Number of Incoming Calls)

When it does the calculations some times the cs_acd_trk_c + cs_acd_ext_c (number of incoming calls) is zero.

I dont know how to get around this ... i tried to set that value to <>0 in my query but it threw my other numbers off for number of calls which is a different value on the report.
Any Help on this would be super appreciated.
Thanks,
Mitch

View 2 Replies View Related

Divide By Zero Error Only With Top

Sep 27, 2006

In the following expression, the query executes with no errors (there are sometimes 0's and nulls in IRON and ENERGY):

SELECT * FROM gff2vg

WHERE (gff2vg.ENERGY > 0 and gff2vg.IRON > 0)

order by IRON/ENERGY desc

but when TOP is added there is a divide by zero error. Is there a way to avoid this?

SELECT TOP(64) * FROM gff2vg

WHERE (gff2vg.ENERGY > 0 and gff2vg.IRON > 0)

order by IRON/ENERGY desc



Thanks.

View 7 Replies View Related

#Error Using IIF And Divide By Zero

Jan 19, 2007

I am getting an error in a calculated field that could potentially divide by zero, even though I'm using an IIF. The column displays in the report as "#Error". My expression looks like this:


= IIF(Fields!Qty.Value = 0, "None", Fields!Hours.Value / Fields!Qty.Value)

I have successfully used this approach with INT fields, but this time the Hours field is a NUMERIC(9,2). My workaround is to do this:


IIF(Fields!Qty.Value = 0, "None", IIF(Fields!Qty.Value = 0, 42, Fields!Hours.Value) / Fields!Qty.Value)
I guess the 42 is cast to an INT inside the second IIF and the calculation works.
What's strange is that the division would even be carried out in the event of Qty = 0 from the first IIF, because the expression should just evaluate to "None" and that would be that.
Has anybody run into this problem? Is my workaround the recommended approach?
-Larry

View 14 Replies View Related

Divide By Zero Error SQL SERVER

Jul 31, 2006

Hi
Is there a way to prevent this error?
I'm getting it from query line:
10000 * (SELECT count(filial_cotacao) from negocios_cotacoes where filial_cotacao = cod_filial)) / (22 * 6 * (SELECT count(filial_cotacao) from negocios_cotacoes where filial_cotacao = cod_filial)),1) 'Atingimento Semestre'
Thanks a lot

View 2 Replies View Related

OLAP - Divide By Zero Error??

Sep 5, 2001

Some of my calculated members look like "######" in Excel and I believe it is because of divide by zero errors. I have tried right clicking on the table, selecting "Table Options" and "For error, values, show:" I have enter 0. This is not working.
Does anybody know how to get rid of this.

Thanks,
Ruaidhri.

View 1 Replies View Related

Divide By Zero Error Encountered

Oct 31, 2013

I have one table with columns patientName , Nurse,ArrivalDate, DepartDate . It has all the patiet information for all the Nurses.

I am calculating Average Number of patients per day per nurse by using below query

SELECT Nurse,
COUNT(DISTINCT patientName) AS NoOfPatients,
COUNT(DISTINCT patientName) * 1.0/COUNT(DISTINCT ArrivalDate) AS [AvgNo.ofpatientsPerDay]
FROM Table t
GROUP BY NURSE

but if ArrivalDate is Null I am getting below error saying that Divide by zero error encountered.

View 5 Replies View Related

How To Avoid Divide By Zero Error

Nov 6, 2013

I have some SQL scripts for SQL Views and getting divide by zero error. I am using

COALESCE(Field1,Field2,1)/COALESCE(Field3,Field4,1)

This function can avoid NULL but how I can avoid 0 ?

Is there any function in SQL that can take care both NULL and 0 and replace it with 1.

View 5 Replies View Related

Divide By Zero Error Encountered.

Dec 3, 2007

How can i handle this kind of error in my execution of my storedprocedure? Error:Divide by zero error encountered.

thanks!

Funnyfrog

View 3 Replies View Related

Wht Does This Give Divide By 0 Error?

May 24, 2007

I am using iif which works just fine in Access to prevent divide by zero errors but this:



=iif(Fields!oh_ret.Value<>0,(Fields!oh_ret.Value-Fields!oh_cost.Value)/Fields!oh_ret.Value,"")



Fails



As Does:





=iif(Fields!oh_ret.Value=0,"",(Fields!oh_ret.Value-Fields!oh_cost.Value)/Fields!oh_ret.Value)



Why? How do I get around this?

View 4 Replies View Related

Transact SQL :: Divide By Zero Error

Oct 25, 2015

I have an equation 

( ( P.RealisedConsumption / ( NULLIF(( PO.ActualQty * P.QuantityPO ), 0) / NULLIF(1000000, 0) ) ) - 1 ) * 100 AS FibreScrapFactor

This works for the example order that I am looking at.  However if i take out the where clause (so i have all orders) i get divide by zero error.  

If I limit the / 1000000 to 10 which i then have 

( ( P.RealisedConsumption / ( NULLIF(( PO.ActualQty * P.QuantityPO ), 0) / NULLIF(10, 0) ) ) - 1 ) * 100 AS FibreScrapFactor

This works for all orders, but is incorrect I need to divide by a million.  How can I get this to work?

View 3 Replies View Related

T-SQL (SS2K8) :: Eliminating Divide By Zero Error

Oct 21, 2014

Being one step removed from innumerate, I was wondering whether there was a more elegant way to avoid divide by zero error instead of trudging through a bunch of isnulls.

My intuition tells me that since multiplication looks like repeated addition, that maybe division is repeated subtraction?
If that's true is there a way to finesse divide by zero errors by somehow reframing the statement as multiplication instead of division?

The sql statement that is eating my kishkas is

cast(1.0*(
(ISNULL(a.DNT,0)+ISNULL(a.rex,0)+ISNULL(a.med,0))-(ISNULL(b.dnt,0)+ISNULL(b.rex,0)+ISNULL(b.med,0))/
ISNULL(a.DNT,0)+ISNULL(a.rex,0)+ISNULL(a.med,0)) as decimal(10,4)) TotalLossRatio

Is there a way to nucleate the error by restating the division? My assertion underlying this statement is that the a alias represents a premium paid, so between medical, pharmacy and dental, there MUST BE at least one premium paid, otherwise you wouldn't be here. the b alias is losses, so likewise, between medical, pharmacy and dental, there MUST BE at least one loss (actually, it just occurred to me that maybe there are no losses, but that would be inconceivable, but ill check again)) so that's when it struck me that maybe there's a different way to ask the question that obviates the need to do it by division.

View 6 Replies View Related

Reporting Services :: Divide By Zero Error

Apr 15, 2015

I have SSRS 2012 and have a report with an expression shown below.  I am getting an error of

"[rsRuntimeErrorInExpression] The Value expression for the textrun ‘Textbox133.Paragraphs[0].TextRuns[0]’ contains an error: Attempted to divide by zero."

Textbox 133 has an expression as shown below and I cannot figure out why I get the error because I thought the IIF would bypass divide by zero.

=IIF(Sum(Fields!PriorQty.Value) = 0.0, 1,(Sum(Fields!CurrentQty.Value) - Sum(Fields!PriorQty.Value)) / Sum(Fields!PriorQty.Value))

View 10 Replies View Related

Transact SQL :: Divide By Zero Error Encountered

Jun 18, 2015

My Code is

SELECT    Client,State,    
CASE WHEN Weight>=11 and Weight<=455 and Height>=110 and Height<=250
  THEN isnull((cast(nullif(Weight,0)/power((NullIf(Weight,0)/100),2) as int)),0) else -1 end as BaseBMIScore
FROM Test100 

And I got following error:

Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.

View 4 Replies View Related

Getting Error When Divide By Zero For Percent Increase

May 8, 2008

Does anyone know how to get over their dreadfull divide by zero error. I keep getting the error, i have changed this code so much. I need to get the percent increase from 2007-2008 ("Total") in this table grouping. I know im getting the error in some of the fields, because sometimes the total is 0 and sometimes the 2007 is 0. What do i do?





Code Snippet

=IIF(Sum(iif(Fields!Column_Text.Value = "Total", Cdbl(Fields!Period_1.Value), 0.0))=0,"0%",
Sum(iif(Fields!Column_Text.Value = "Total", Fields!Period_1.Value,nothing))- Sum(iif(Fields!Column_Text.Value = "2007", Fields!Period_1.Value, nothing)))/ IIF(Sum(iif(Fields!Column_Text.Value = "2007", Fields!Period_1.Value, nothing))=0,1,Sum(iif(Fields!Column_Text.Value = "2007", Fields!Period_1.Value, nothing)))

View 1 Replies View Related

Workaround Divide By Zero Error Encountered Message

Jan 7, 2004

Hey all,

When i exec an sp it runs a sum, sometimes it is possible that there is a 0 value, it then returns an error Divide by zero error encountered
How can i work around this error

My sp code is

CREATE proc CP_avgloss_rings
@mID varchar(10),
@startdate datetime,
@enddate datetime
as
select ((sum(vtp)-(sum(moneyout)))/100) / ((sum(playtime))/ 3600) as avgloss
from dbo.rings
where
machineID = @mID
and convert(varchar,njdate,121)
between convert(varchar,@startdate,121)
and convert(varchar,@enddate,121)
GO


Maybe someone can help me
Cheers Wimmo

View 4 Replies View Related

Divide By Zero Error Encountered - Null Value Eliminated

Mar 19, 2015

I'm getting this error:

Divide by zero error encountered.
Warning: Null value is eliminated by an aggregate or other SET operation.

this is where i'm getting the error:

CASE WHEN Claims.ClaimTotal > 0 then (ISNULL(Claims.ClaimTotal,0) / ISNULL(TotalPrem.TotalPrem,dbo.TrnPolicy.TotalDue)) else 0 END AS LossRatio

View 3 Replies View Related

Transact SQL :: Divide By Zero Error In Empty Function

Oct 9, 2015

I have a work database where I implemented a table-valued function. One colleague of mine reported to me that this function gave a Divide by Zero error when executed with some specific values given to its arguments (there are a 15 arguments). Then I started debugging, and I introduced some exit points to the function before its end in order to detect the point where the error appeared, since I don't have access to the database server and I cannot use the debugging tools from remote, due to the network configuration of my office. I can only do attempts on the code to try to find a solution.

Since I didn't manage to get rid of this error, I decided to make a silly and desperate attempt: I put a RETURN statement immediately after the BEGIN of the function body, with the idea that the function should not raie any error if it exit immediately after its beginning, despite the fact that this results in an empty table in return.

The result of my attempt is that the Divide by Zero error is still THERE (!), even if my function looks like

ALTER FUNCTION [dbo][<myFuncName>](...parameters...) RETURNS TABLE (...table definition...) AS BEGIN 
RETURN
END 
GO

How I can check it.

View 5 Replies View Related

Transact SQL :: How To Get Percentahe Profit Without Error In Zero Divide

Nov 4, 2015

How can I get the value (pr_profit / pr_sales ) * 100,  (cur_profit / cur_sales) * 100 for %profit. When I am giving zero devide error  is coming . How can I give  if pr_profit = 0 then % profit should be zero.

SELECT  
SUM(CASE WHEN invdate >= {d '2015-01-01' } and invdate <={d '2015-11-03' } Then linetotal Else 0 End) as cur_Sales,
SUM(CASE WHEN invdate >={d '2014-01-01' } and invdate <= {d '2014-11-03' } Then linetotal - linecost Else 0 End) as pr_Profit,
SUM(CASE WHEN invdate >= {d '2015-01-01' } and invdate <={d '2015-11-03' } Then linetotal - linecost Else 0 End) as cur_Profit,
SUM(CASE WHEN invdate >= {d '2015-01-01' } and invdate <={d '2015-11-03' } Then linetotal - linecost Else 0 End) -

[code]...

View 5 Replies View Related

Divide By Zero Error Encountered. Error

Mar 17, 2008

the query is below ;

Select Model, Kota as [Çıkan Anket]
,
(Select Count(*) From dbo.Main Where RuhsatSahibiModel = tt.Model) as [Verilen Adres] , (Select Count(RuhsatSahibiSahisID) From dbo.Main Where DurumKoduID in(1,2,3,4,5,6,9,12,13,14,15,16,17,20,21,22,23,24,25,26,27,28) and RuhsatSahibiModel = tt.Model) as [Donen Adres]

,

(Select Count(*) From dbo.Main Where DurumKoduID = 2 and RuhsatSahibiModel = tt.Model) as [Donen Anket] ,((Select cast(Count(*) as decimal(2,0)) From dbo.Main Where DurumKoduID = 2 and RuhsatSahibiModel = tt.Model ) / (Select top 1 (cast(Kota as decimal(2,0))) From dbo.Model Where Model = tt.Model))*100 as [Oran]

,

(Kota - (Select Count(*) From dbo.Main Where DurumKoduID = 2 and RuhsatSahibiModel = tt.Model)) as [Kalan Anket] , ((Select Count(*) From dbo.Main Where RuhsatSahibiModel = tt.Model)- (Select Count(RuhsatSahibiSahisID) From dbo.Main Where DurumKoduID in(1,2,3,4,5,6,9,12,13,14,15,16,17,20,21,22,23,24,25,26,27,28) and RuhsatSahibiModel = tt.Model)) as [Kalan Adres]

From

(SELECT Model, SUM(Kota) AS Kota FROM dbo.Model GROUP BY Model) as tt where tt.Model in('A3')



it's returning error message : "Divide by zero error encountered."

View 3 Replies View Related

Trapping Errors In SPs

Dec 28, 1999

Hi,

Here is what I am trying to do:

CREATE PROCEDURE usp_deleteSomething

@theThing_i char(11)

AS

BEGIN

SET NOCOUNT ON

delete from myTable where thing=@theThing_i

return(@@ERROR)


END

I thought this SP would return 547(foreign key constraint voilation) when column 'thing' was being referenced in another table. Instead, when the front-end application code calls this SP it gets a 1 from the delete statement itself. In other words, my return statement never seems to get executed. Is there any way of achieving this? In other words, I want to trap the error 547 and return that to the front-end.

Any replies would be greatly appreciated.

Thanks in advance,

Nishi

View 2 Replies View Related

Trapping Errors

Jul 20, 2005

Hi,I have a stored proc StoredProc1 ={INSERT INTO Table1SELECT *FROM View1Return @@ERROR}StoredProc1 is used in another sp StoredProcMain ={(some code before)...EXEC @iResult = StoredProc1If @iResult <> 0BEGINROLLBACK TRANSACTIONReturn @iResultEND.... (continue)}So I want to rollback if StoredProc1 is not successful.Then I ran into a problem. I added a column to Table1 but forgot toupdate View1 to add the equivalent column. When I executedStoredProc1, I got the "Insert Error: Column name or number ofsupplied values does not match table definition." But the error isNOT trapped. It seems the instruction "Return @@ERROR" returns 0 andStoredProcMain goes on as if there wasn't an error.How can I trap this error?ThanksWalter

View 2 Replies View Related

DTS - Trapping SQL Errors

Mar 23, 2006



I am panning to write a DTS package whcih alter the table and output any error messages if the alter statement fails.

I have created Execute SQL Task in which I have wrote the following command.

Alter table Employee ADD EmpStatus char(4) DEFAULT A not null;

I have created a work flow to write the error message to a text file. But I am having trouble to trap the error message prduced by the Alter statement (like "column names in each table must be unique. Column name specified int the table more than once").

Any help will be appreciated.

Thanks

Sankar

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved