August 8, 2006 at 5:14 am
Hi Guys!Pl help me if you can!I'm having a table in which a column is having int datatype. When non-int (char) data is being inserted, it is terminating the application although error handling is there in sp. When I analysed, I found control is not at all transferred to the error handling.Thanks in adv.Ashesh
August 8, 2006 at 5:19 am
You must catch an error in the very next statement after attemting insert.
_____________
Code for TallyGenerator
August 8, 2006 at 6:43 am
You cannot trap this error in sp only the application, SQL Server will not execute any statement following this type of error.
The only exception may be SQL 2005 with TRY...CATCH
Far away is close at hand in the images of elsewhere.
Anon.
August 9, 2006 at 12:41 am
Since the error is caused by the attempt to convert a column's data type, simply add a WHERE clause that will exclude all rows where this column's data cannot be converted.
An alternative to the WHERE is to use:
IntField = CASE WHEN IntInChar LIKE '[0-9]' THEN IntInChar ELSE NULL END
To NULL that column value for the rows that cannot be converted to int.
Just depends on what you want done with the "bad" data.
Andy
August 9, 2006 at 2:50 am
Nice one Andy
After I posted I thought of posting similar but didn't
If the input is greater than one char then use the following
LIKE '[0-9-]' + REPLICATE('[0-9]',LEN([column])-1)
Far away is close at hand in the images of elsewhere.
Anon.
August 9, 2006 at 3:11 am
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply