Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

Where is my database stored on the hard disk in ms sql server?

1061


What is the sql server agent?

1091


How do I start sql server 2017?

942


What is relationship? What number of sorts of relationship are there?

1141


How many types of schemas are there?

1042


What is NOT NULL Constraint in sql server 2012?

1001


What is page in sql server?

948


which backup strategy you are following at ur company

2148


You want to use bids to deploy a report to a different server than the one you chose in the report wizard. How can you change the server url?

155


How do I port a number to sql server?

1039


Write a SQL command to insert and update only a particular field?

1112


What are the restrictions that views have to follow? : SQL Server Architecture

1001


How do I get Report Builder to generate a parameter that can be set by users viewing the report?

150


What is data block and how to define data block size?

1027


What is the index requirement in SQL Azure?

98