Handling CAST Error On The Fly

Mar 26, 2002

I want to load a smallint field with values from a varchar field; e.g. CAST(field as SMALLINT). This is in a bulk copy insert so of course there are the few fields that have '1773A' for example and error out the CAST. Anyone know of a way to return 0 (or 1) if CAST errors on conversion ?

This is the test script that's trying to convert 3750 records (an unknown minority of records contain alpha characters):

create table alstest (field1 smallint)
insert into alstest (field1)
select CAST(conf_number AS SMALLINT) from conference

View 1 Replies


ADVERTISEMENT

Enable Error Handling When Writing Custom Source Component /custom Error Handling Component.

Apr 21, 2006

1) We are writing a custome Source component for Oracle with OCI calls, Could some one please let me know how to Enable Error Handling for the Same,

2) Is it possible to write Custome Error Handeling Component for SSIS? if yes could you please help me on how to write it.

Thanks in advance.

View 1 Replies View Related

Error Handling In MSSQL - If Error During Call Remote Stored Prcedure I Need SQL Code To Continue...

Jul 20, 2005

Hi All,I want to catch the next MSSQL error in my SQL code with following continuecalculationsServer: Msg 17, Level 16, State 1, Line 1SQL Server does not exist or access denied.If REMOTE_SERVER_1 is inaccessible (as in (a) below) the executing of SQLwill not continue with (b) - I need the code in (b) to run despite whetherthe previous exec was successful or not - Any ideas?begin transaction(a) exec REMOTE_SERVER_1...bankinsert '1' , '1' , 1 , 0 , 0(b) print @@errorcommit transactionwhere REMOTE_SERVER_1 is link to server created byEXEC sp_addlinkedserver @server = 'REMOTE_SERVER_1', @srvproduct = '',@provider = 'SQLOLEDB', @datasrc = 'MYCOMP1', @catalog = 'mirror2'EXEC sp_addlinkedsrvlogin @rmtsrvname = 'REMOTE_SERVER_1', .....Exec sp_serveroption 'REMOTE_SERVER_1', 'data access', 'true'Exec sp_serveroption 'REMOTE_SERVER_1', 'rpc', 'true'Exec sp_serveroption 'REMOTE_SERVER_1', 'rpc out', 'true'Exec sp_serveroption 'REMOTE_SERVER_1', 'collation compatible', 'true'Any help will be greatly appreciated

View 1 Replies View Related

Error When Using Cast

Dec 10, 2007

Hi, I'm very new to SQL. Trying to sum two fields, but I have to change the datatype first. Here's the code and the error message I receive. Any help would be appreciated.

SELECT TS_RESPONSIBLE, TS_STATUS, TS_USER_07, SUM(TS_USER_07 * TS_STATUS) AS value
FROM TEST_54_VW
GROUP BY TS_RESPONSIBLE, TS_STATUS, TS_USER_07
WHERE CAST(TS_USER_07 AS INTEGER)

Incorrect syntax near the keyword 'WHERE'.

View 13 Replies View Related

CAST Error

Jan 12, 2006

I am keep getting error when I use CAST function in Expression.

If I run (DT_I4)("1")  I got following error.

 

TITLE: Expression Builder
------------------------------

Cannot convert expression value to property type.

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%u00ae+Visual+Studio%u00ae+2005&ProdVer=8.0.50727.42&EvtSrc=Microsoft.DataTransformationServices.Controls.TaskUIFramework.TaskUIFrameworkSR&EvtID=CannotAssignExpressionToProperty&LinkId=20476

------------------------------
ADDITIONAL INFORMATION:

Cannot convert 'System.Int32' to 'System.Int64'.

------------------------------
BUTTONS:

OK
------------------------------

View 1 Replies View Related

Cast Error, Please Help!

Jan 3, 2008

I'm encountering a Cast error, and find I am very much out of my league... I'm using a Derived Column Transformation to convert a column that comes from an Excel spreadsheet from a non-standard date format to DT_Date, though I picked this format simply because it was the first date format I found in the pick list. When I upload the ETL into Management Studio and run it I get the following error:




Code Block

Date,Source,Severity,Step ID,Server,Job Name,Step Name,Notifications,Message,Duration,Sql Severity,Sql Message ID,Operator Emailed,Operator Net sent,Operator Paged,Retries Attempted
01/03/2008 07:27:52,Force_Receipt_To_Clear_From_Excel,Error,0,WFM-SQL1-RDM,Force_Receipt_To_Clear_From_Excel,(Job outcome),,The job failed. The Job was invoked by User Removed. The last step to run was step 1 (Run Force_Receipt_To_Clear_From_Excel).,00:00:35,0,0,,,,0
01/03/2008 07:27:52,Force_Receipt_To_Clear_From_Excel,Error,1,Sever_Name_Removed,ETL_NAME_REMOVED,Run ETL_NAME_REMOVED,,Executed as user: Removed. ....00.3042.00 for 32-bit Copyright (C) Microsoft Corp 1984-2005. All rights reserved. Started: 07:27:52 Error: 2008-01-03 07:28:25.12 Code: 0xC0202009 Source: Data Flow Task OLE DB Destination [232] Description: SSIS Error Code DTS_E_OLEDBERROR. An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Invalid character value for cast specification". An OLE DB record is available. Source: "Microsoft SQL Native Client" Hresult: 0x80004005 Description: "Invalid character value for cast specification". End Error Error: 2008-01-03 07:28:25.14 Code: 0xC020901C Source: Data Flow Task OLE DB Destination [232] Description: There was an error with input column "ASSIGNED_TO_DISPATCH" (2020) on input "OLE DB Destination Input" (245). The column status returned was: "Conversion failed because ... The package execution fa... The step failed.,00:00:35,0,0,,,,0


The data that is being converted appears as one of two things. First it can appear as a string value with 0 characters (that does not appear a Null oddly). Second it will appear as a string value representing a date in the following format 01022008 7:38 which is a date in the following the format 2 Digit Month, 2 Digit Day, 4 Digit Year, Space Time in Military Time.



The expression I'm using to convert the String data type to a Date is:



Code Block

LEN([Completed Date Time]) == 0 || ISNULL([Completed Date Time]) ? NULL(DT_DATE) : (DT_DATE)(SUBSTRING([Completed Date Time],1,2) + "/" + SUBSTRING([Completed Date Time],3,2) + "/" + SUBSTRING([Completed Date Time],5,10))




View 1 Replies View Related

Error: Specified Cast Is Not Valid.

Jul 11, 2006

 
 
  sqlConnection1.Open();
System.Data.SqlClient.SqlDataReader Dil1;
Dil1 = sqlDilGetir.ExecuteReader();
ddlDil1.Items.Add(new ListItem("1. Dil", ""));
while (Dil1.Read())
{
ddlDil1.Items.Add(new ListItem(Dil1.GetString(1), Dil1.GetString(0)));
}
Dil1.Close();
sqlConnection1.Close(); 

View 7 Replies View Related

GetString Got Cast Error

Apr 1, 2008

I used SQLDataReader to assign a OrderID to a text box.
OrderID is varchar type. I got cast error. How to fix it?
Me.txtOrderID.Text = myDataReader.GetString("OrderID")

View 6 Replies View Related

Select Cast Error

Jul 20, 2005

name1 field is is nvarchar(40).(1)select case when isnumeric(name1) = 1 thencast(name1 as int) else null end as nameIn (1) when name1 is not numeric, name is null andits type becomes number not string(40).And,(2)select case when isnumeric(name1) = 1 thencast(name1 as int) else name1 end as nameIn (2) when name1 is Not numeric it gives error:can not cast name to int.Basically, i like to convert name1 to Integer if it isnumeric or keep it in its origianl nvarchar(40) if itis Not numeric. how?.--Sent by 3 from yahoo element from comThis is a spam protected message. Please answer with reference header.Posted via http://www.usenet-replayer.com

View 2 Replies View Related

DB Engine :: Error Specified Cast Is Not Valid

May 25, 2015

I have a backup of DB with version Microsoft sql 2012 and i need restore this data base on instance Microsoft sql 2008 R2
when i try restore database on SQL server 2008 R2  i have the error:

Specified cast is not valid.
(SqlManagerUI)

View 6 Replies View Related

Error Handling - How To Suppress An Informational Error?

Nov 1, 1999

Hello,

I would like to supress an Informational error that SQL is returning when I run a stored proc that I created. The error message returned is:

Warning: Null value eliminated from aggregate.

The values returned from the stored proc are the results from a 'select * from #tmp_tbl". Before returning the values, I simply create the temp table, populate it and then run the select statement. Prior to getting my results, I get the error message. Can I suppress it and how?

Thank you.

View 1 Replies View Related

SQL 2012 :: Cast Varchar To Bigint Error

Mar 4, 2014

I try to run code but got an error. How to fix it?

SELECT Cast(('20140304800084500001') AS BIGINT)

Arithmetic overflow error converting expression to data type bigint

View 1 Replies View Related

BCP Error Invalid Character Value For Cast Specif

Apr 30, 2008

I'm usung bcp to move data from one table to another. 202 million rows. The source/original table had 32 fields. The new table has 33 fields. I added a PK column to the destination/new table. The new PK column is the first field in the new table, it is set to autoincrement by 1 on each insert. The data file only has 32 fields of data per row.


The error is :SQLState = 22018, NativeError = 0 Error = [Microsoft][SQL Native Client]Invalid character value for cast specification

10 times, then bcp shuts off (default errors is 10).

C:>bcp dbname.schema.TP_LOG_NEW in e:alltplog.dat -S
dbsvr -T -f tplognew.fmt

tplognew.fmt:
9.0
33
1 SQLCHAR 0 41 " " 1 TP_LOGID_PK ""
2 SQLCHAR 0 41 " " 2 TP_LOG_ID ""
3 SQLCHAR 0 20 " " 3 PROCESS_TYPE SQL_Latin1_General_CP1_CI_AS
4 SQLCHAR 0 20 " " 4 SEVERITY_CODE SQL_Latin1_General_CP1_CI_AS
5 SQLCHAR 0 41 " " 5 TP_ERROR_REF_ID ""
6 SQLCHAR 0 41 " " 6 TP_PARTNER_ID ""
7 SQLCHAR 0 41 " " 7 TP_CUSTOMER_ID ""
8 SQLCHAR 0 500 " " 8 DESCRIPTION SQL_Latin1_General_CP1_CI_AS
9 SQLCHAR 0 255 " " 9 PROCESS_REF_ID SQL_Latin1_General_CP1_CI_AS
10 SQLCHAR 0 255 " " 10 PROCESS_NAME SQL_Latin1_General_CP1_CI_AS
11 SQLCHAR 0 24 " " 11 PROCESS_ARGUMENT_1 ""
12 SQLCHAR 0 24 " " 12 PROCESS_ARGUMENT_2 ""
13 SQLCHAR 0 24 " " 13 PROCESS_ARGUMENT_3 ""
14 SQLCHAR 0 24 " " 14 PROCESS_ARGUMENT_4 ""
15 SQLCHAR 0 41 " " 15 PROCESS_ARGUMENT_5 ""
16 SQLCHAR 0 41 " " 16 PROCESS_ARGUMENT_6 ""
17 SQLCHAR 0 41 " " 17 PROCESS_ARGUMENT_7 ""
18 SQLCHAR 0 41 " " 18 PROCESS_ARGUMENT_8 ""
19 SQLCHAR 0 500 " " 19 PROCESS_ARGUMENT_9 SQL_Latin1_General_CP1_CI_AS
20 SQLCHAR 0 500 " " 20 PROCESS_ARGUMENT_10 SQL_Latin1_General_CP1_CI_AS
21 SQLCHAR 0 500 " " 21 PROCESS_ARGUMENT_11 SQL_Latin1_General_CP1_CI_AS
22 SQLCHAR 0 500 " " 22 PROCESS_ARGUMENT_12 SQL_Latin1_General_CP1_CI_AS
23 SQLCHAR 0 41 " " 23 USER1 ""
24 SQLCHAR 0 24 " " 24 USER2 ""
25 SQLCHAR 0 255 " " 25 USER3 SQL_Latin1_General_CP1_CI_AS
26 SQLCHAR 0 255 " " 26 USER4 SQL_Latin1_General_CP1_CI_AS
27 SQLCHAR 0 255 " " 27 USER5 SQL_Latin1_General_CP1_CI_AS
28 SQLCHAR 0 32 " " 28 CREATED_BY SQL_Latin1_General_CP1_CI_AS
29 SQLCHAR 0 24 " " 29 CREATED_DATE ""
30 SQLCHAR 0 32 " " 30 CREATED_PROCESS SQL_Latin1_General_CP1_CI_AS
31 SQLCHAR 0 32 " " 31 MODIFIED_BY SQL_Latin1_General_CP1_CI_AS
32 SQLCHAR 0 24 " " 32 MODIFIED_DATE ""
33 SQLCHAR 0 32 "
" 33 MODIFIED_PROCESS SQL_Latin1_General_CP1_CI_AS


New table definition:

CREATE TABLE [schema].[TP_LOG_NEW](
[TP_LOGID_PK] [numeric](18, 0) IDENTITY(1,1) NOT NULL,
[TP_LOG_ID] [numeric](18, 0) NOT NULL,
[PROCESS_TYPE] [varchar](20) NOT NULL DEFAULT (),
[SEVERITY_CODE] [varchar](20) NOT NULL DEFAULT ('0'),
[TP_ERROR_REF_ID] [numeric](18, 0) NOT NULL DEFAULT ((0)),
[TP_PARTNER_ID] [numeric](18, 0) NULL,
[TP_CUSTOMER_ID] [numeric](18, 0) NULL,
[DESCRIPTION] [varchar](500) NULL,
[PROCESS_REF_ID] [varchar](255) NULL,
[PROCESS_NAME] [varchar](255) NULL,
[PROCESS_ARGUMENT_1] [datetime] NULL,
[PROCESS_ARGUMENT_2] [datetime] NULL,
[PROCESS_ARGUMENT_3] [datetime] NULL,
[PROCESS_ARGUMENT_4] [datetime] NULL,
[PROCESS_ARGUMENT_5] [numeric](18, 0) NULL,
[PROCESS_ARGUMENT_6] [numeric](18, 0) NULL,
[PROCESS_ARGUMENT_7] [numeric](18, 0) NULL,
[PROCESS_ARGUMENT_8] [numeric](18, 0) NULL,
[PROCESS_ARGUMENT_9] [varchar](500) NULL,
[PROCESS_ARGUMENT_10] [varchar](500) NULL,
[PROCESS_ARGUMENT_11] [varchar](500) NULL,
[PROCESS_ARGUMENT_12] [varchar](500) NULL,
[USER1] [numeric](18, 0) NULL,
[USER2] [datetime] NULL,
[USER3] [varchar](255) NULL,
[USER4] [varchar](255) NULL,
[USER5] [varchar](255) NULL,
[CREATED_BY] [varchar](32) NULL,
[CREATED_DATE] [datetime] NULL,
[CREATED_PROCESS] [varchar](32) NULL,
[MODIFIED_BY] [varchar](32) NULL,
[MODIFIED_DATE] [datetime] NULL,
[MODIFIED_PROCESS] [varchar](32) NULL,
CONSTRAINT [PK_TP_LOG_NEW] PRIMARY KEY CLUSTERED
(
[TP_LOGID_PK] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

View 1 Replies View Related

Order By Case Cast Convert Error

Jul 23, 2005

I have created a SQL Stored Procedure that uses a Case statement todetermine the Order By. For one of the Case statements I am trying toturn a Char field into Datetime in for the Order By, however I can notget it to work. Can someone please take a look and my code below andtell me what I am doing wrong. Thank you.ORDER BYCASE WHEN @SortBy = 'dttm_stamp' THEN dttm_stamp End,CASE WHEN @SortBy = 'Event_Date1' THEN CAST(CONVERT(char(10),Event_Date1,101) as datetime) End,CASE WHEN @SortBy = 'FullName' THEN Emp_lastname + ', ' +Emp_firstname End,CASE WHEN @SortBy = 'FullName Desc' THEN Emp_lastname + ', ' +Emp_firstname End DESC,CASE WHEN @SortBy = 'Emp_SSN' THEN Emp_SSN End

View 11 Replies View Related

SSIS Error: Unable To Cast COM Object

Oct 10, 2007

Hi,

I get the following error opening an existing (or working) ssis package on my new server.

Error loading 'TestExecutionFromScript.dtsx' : Unable to cast COM object of type 'Microsoft.SqlServer.Dts.Runtime.Wrapper.PackageNeutralClass' to interface type 'Microsoft.SqlServer.Dts.Runtime.Wrapper.IDTSContainer90'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{8BDFE892-E9D8-4D23-9739-DA807BCDC2AC}' failed due to the following error: Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED))..

I found in a blog that this is caused due to a dll which is not registered ("DTS.dll")

Can anyone try to explain the exact reason for this? I am not even able to execute a package from the command prompt using the dtexec utility. I have "Microsoft SQL Server Analysis Services Designer Version 9.00.3042.00" on my server. My other machine which executed this package successfully was running "Microsoft SQL Server Analysis Services Designer Version 9.00.1399.00".

Thanks very much for any kind of help.

View 3 Replies View Related

Invalid Char Value Cast Spec Error

Nov 15, 2007

First, I hope this is in the correct spot.

I'm trying to build a SS 2005 db from a Sqlbase database and I have coded a program to bring over the data and insert. The problem I'm having is that on some of the tables, I'm getting an "Invalid character value for cast specification" error on an insert. I've found the offending row and discovered that it's an integer that is null in the source table.

The weirdness is, that in SqlServer, it is defined as an "int" column that can be null. I can insert the row through both Management console (connected natively) and through a sql utility from Sqlbase/Gupta (called sqltalk) connected thru ODBC. The problem is when I try the insert through OLEDB within the application, that's when I get the error. I changed the value from null to zero in the source table then it works. I think there must be a "set **** on" on the connection that I'm missing if I can enter the SAME data using Management console but I'm not sure what that is. I don't want to have to find ALL occurences of null integers in my entire database just to insert it into SqlServer.

Has anyone else had this problem??

View 3 Replies View Related

Handling @@error

Apr 16, 2008

Hi there,
         Can anyone help me in catching @@error value.
I have a stored procedure which return @@error value, I  need to read that in my dataaccesslayer and act according to it.
how do I catch the return value from stored procedure in my dataaccesslayer.
if I am not wrong @@error return a bool value
 
Thanks in advance.

View 1 Replies View Related

Error Handling

May 1, 2008

dear friends i am writng a store procedure to insert into a two table .table 1 data inserted but when i inserting into a table2 it have some error  at that time table 1 data also want to delete.give suggestions

View 3 Replies View Related

Error Handling

Mar 14, 2000

I am writing a stored procedure that loads transaction logs to a database and I am having trouble trapping meaningful error messages. When ever the load fails, it gives me two error messages, the first one is meaningful and the second one just states that the load ended abnormally. Unforunately, when I capture the error using @@error after the load statement, it is the second error message that I am getting.

Is there anyway to trap the first error message as well?

Thanks
Angela

View 1 Replies View Related

DTS And Error Handling

Jan 21, 1999

I currently have defined a source server, a transformation, and a destination server using DTS. How and where do I create an error routine that would capture any and all errors that would occur. This would include connection error, transformation errors etc. I know the errors can be written out to a text file but I would like them written to a table on my destination server.

The DTS package will be called from an external program using the xp_cmdshell extended stored procedure. We are using it this way as a flag so if one transformation fails it will return a 1. If all are successful it will return a O. These will be our flags to check the errors table in the destination server.

Could someone tell me where this code is to go and what the code will look like. Samples would be the most help.

Thanks

Tom

View 1 Replies View Related

Error Handling??

May 21, 2004

is there any way to do sometype of Error handling with in a Stored Proc? Example, If I have a deadlock, can I trap that error and execute other sql code or will always simply kill the stored proc?

View 1 Replies View Related

T-SQL Error Handling

Dec 12, 2006

I have a composite unique key on the audit_hub table that includes TimeStamp, UID, Type, Mailbox all as part of the unique key.

I’m trying to do inserts, and know that in some cases I will violate unique index.

I’m using stored procedure, and want to handle the error gracefully there – just move on.

Reading from text-based log files via .vbs and get back the nasty popup window.

Looks like I have it right but obviously I don’t considering how it’s (not) working.

I thought error handling would be the simplest way to avoid dupe records. Might be necessary to run the same log in more than once, and only want to add the new records since the last insert session.

Here’s what I have. It obviously simply halts and complains immediately after the insert attempt.


ALTER procedure eml_HubInsert
@TimeStamp bigint
,@UID varchar(255)
,@Type varchar(255)
,@MailBox varchar(255)
,@ServerID varchar(50)
as
insert into audit_hub (TimeStamp,UID,Type,Mailbox,ServerID)
values (@TimeStamp,@UID,@Type,@MailBox,@ServerID)

if @@ERROR = 2601
begin
return 0
end

View 2 Replies View Related

Error-Handling ?

Jul 25, 1998

Hallo... and sorry about my english

1 question:
What Error-Handling msut i mplement in a trigger, who is updating permanently two tables
in a database (with the follow commands: insert, delete and update) ???

thank you !

View 1 Replies View Related

Error Handling

Dec 5, 2005

I have some stored procedures that insert information from a third party plugin that hooks into our database (so I can't do any client side validiation). The problem I am encountering is that some of the fields I use need to be in DateTime format. In order for SQL SERVER 2000 to be able to insert this field, the Date has to be in the correct syntax or an error is thrown.

Is there any way to do something like this in SQL SERVER 2000


Code:

DELCARE @SomeDate DateTime

Try
Set @SomeDate = CONVERT(DateTime, Parameter1, 101)
Catch
return custom error describing what field is formatted
wrong and exit stored procedure
END

View 3 Replies View Related

BCP Error Handling

Mar 3, 2005

I am running some bcp copies through a Sql job. I am copying 35 tables in individual steps. However, sometimes the bcp step fails to copy the data, and I want the step to fail if the data is not copied properly. Is that possible? If so, how? Any help is greatly appreciated.

View 2 Replies View Related

Error Handling

Mar 8, 2005

I have this stored procedure that I need to add error handling to. How would I do that??

REATE PROCEDURE November2000
AS
SELECT TM#, LASTNAME, FIRSTNAME, FINALSUITDONE
FROM dbo.EmployeeGamingLicense
WHERE (FINALSUITDONE BETWEEN CONVERT(DATETIME,
'2000-11-01 00:00:00', 102) AND CONVERT(DATETIME,
'2000-11-30 00:00:00', 102))


GO

View 2 Replies View Related

T-sql Error Handling

Feb 2, 2004

ppl,

i wrote this sql, seems v.straightforward to me.
It works first time round, sets the foreigh key, but second time round should error out to the handler - but it just reports the errors to the message out and dosn't seem to fire the errhandler.

Its gotta be a simple mistake - perhaps you could show me.


DECLARE @ErrorMsg int

BEGIN TRANSACTION

ALTER TABLE TPH_GlobalProductHierarchy
ADD CONSTRAINT SalesSubGrp_fk FOREIGN KEY (SalesSubGroupingID)
REFERENCES TPH_SalesSubGrouping (ID)

SET @ErrorMsg =@@ERROR
IF @ErrorMsg <>0 GOTO ErrorHandler

PRINT 'Success'
COMMIT TRANSACTION

ErrorHandler:
IF @ErrorMsg <> 0
BEGIN
PRINT 'Rollback'
ROLLBACK TRANSACTION
END

View 1 Replies View Related

Error Handling

Apr 20, 2004

How can i use the system error messages. With RAISERROR

View 1 Replies View Related

Error Handling

Jun 4, 2008

Can i any one help regd error handling while executing stored procedure.

Sample Sequence of execution :

CREATE procedure RBI_Control_sp
as
begin
set nocount on

begin try
BEGIN TRANSACTION
--Truncating the Table in ramcovm392(fin_ods)
exec fin_ods..trun_sp

--Data Transfer From the Live Server to Dw-Server
exec fin_ods..RBI_Data_Transfer_sp

insert into fin_wh..Status_report([object_name],row,[date])
select 'Data Tranfer','SUCCESS',getdate()

COMMIT TRANSACTION
end try

begin catch
<b> [i need to insert the type of error in status report table]</b>
rollback transaction
insert into fin_wh..Status_report([object_name],row,[date])
select 'Data Tranfer','FAILURE',getdate()
end catch

set nocount off
end

View 2 Replies View Related

Error Handling!!!

Mar 8, 2006

Hi all,

I am calling some stored procedures from ASP. These strored procedures have to deal with lots of deletes and updates. So i have thought of implementing transaction commits and rollbacks. But if a rollback occurs in these stored procedures, i want to get a value back to asp page, based on this value i will run the next stored procedure.

Can anybody give me some examples for doing this.

Somebody please help me with this!!!!!!!!!

Thanks a lot in advance,
Nitu

View 4 Replies View Related

Error Handling In An SP

Jan 5, 2007

hello. below is a very simple SP i have coded to insert a user into my database. i have created a unique index for the username column on my database table. if the username already i want to convey this to my C# code which is attempting the insert. i am using a combination of TRY/CATCH, RAISERROR and @@ERROR here to achieve my aim. could somebody please look at my code and tell me if the error handling code is OK, or is it overly complicated?



AS

SET NOCOUNT ON

DECLARE @Error int;

BEGIN

BEGIN TRY
INSERT INTO Users(
Username,
Password,
FirstName,
Surname,
DateBirth,
Email,
Id_Country)
VALUES(
@Username,
@Password,
@FirstName,
@Surname,
@DateBirth,
@Email,
@Id_Country)
END TRY
BEGIN CATCH

SELECT @Error = @@ERROR;

IF @Error = 2601
RAISERROR('The username already exists.', 15, 1)
ELSE
RAISERROR('An unknown error occurred.', 15, 1)

RETURN @Error;

END CATCH

SELECT @Id_User = SCOPE_IDENTITY()

END

View 1 Replies View Related

Error Handling

Jul 3, 2007

need example on how to add event handling condetion in a package using ssis.
my package runs in a loop. the loop creates a connection to diff servers and runs a dynamic query.
i want to add a feature which would let the loop run in the event of connection failure for one server.

thanks in adv

View 1 Replies View Related

Error Handling

Sep 18, 2007

I have a stored procedure that inserts a new record into a table. The table it inserts into has a unique constraint that utilizes an identity column. Occassionally, this constraint gets violated due to the fact that the app running my stored procedure isn't the only application inserting into the table. Ideally, we would want to change the design to avoid this scenario but these are legacy applications that will eventually be sunsetted. My question is this; is there a way to handle the unique key constraint violation and prevent an exception being thrown in the app calling the stored proc? I know I can check for the error code and handle it within the stored proc but my app still gets an exception caught by the calling method. Can I prevent this from happening? I want for the insert to attempt again and if successful continue processing and not produce the exception. Any help would be greatly appreciated.

View 6 Replies View Related







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