How to handle errors in Stored Procedures.
Answer Posted / senthil
Error handling means if our stored procedure generates any error while running,we can handle that error.So that it will not show the error.
For eg.
insert into emp(sno,name,age) values(10,'Vasanth',26);
Consider field "sno" is primary key.When we are giving duplicate input to the sno it will show the error.
If you dont want to show the error ,you can capture the error and display as below.
BEGIN TRY
insert into emp(sno,name,age) values(10,'Vasanth',26);
END TRY
BEGIN CATCH
SELECT @err = @@error
IF @err <> 0
BEGIN
RETURN @err
END
END CATCH
Here in this case,it will capture the error and display.
| Is This Answer Correct ? | 12 Yes | 1 No |
Post New Answer View All Answers
Explain hostprotectionattribute in sql server 2005?
What are different types of constraints?
What are the types of indexing?
Explain about service Broker functions?
In my application I have a process which picks the scanned files (tif format) from a shared location and it links to application and shown on it.The actuall issue is that my process picks the file before it is completly written or scanned which results in displaying few parts of the image or incomplete image.I need to check if the file is not completly scanned or written then do not link it to application.Please help if any body tell me that how can i check that file is in written phase or locked through DTS.thanking you in advance
How to find out the list schema name and table name for the database?
Is oracle faster than sql server?
What is openxml in sql server?
What is trigger explain with program?
Describe in brief system database.
Mention the different types of triggers?
after migrating the dts packg to ssis by using migrtn wizrd in 2005. iam not able to open ssis pack and getting error. what r those errors? how to resolve?
Explain acid?
What is ddl and dml commands?
How to delete duplicate rows from table except one?