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

What is the recovery model? List the types of recovery model available in sql server?

898


Explain what are the different index configurations a table can have?

1101


What is the need for indexing?

943


Is sql server a database?

983


What is awe?

1005


Why do we use functions?

908


Explain error and transaction handling in sql server?

1005


What are the 2 types of classifications of constraints in the sql server?

1114


Explain error handling in ssis?

1013


What are diverse clauses that form a part of sql?

1064


Would you store your query in a ssrs report or a database server? State the reason why?

152


What is apply operator in sql?

1008


How to make a column nullable?

1109


Introduction of rollup clause using sum and group by clause?

954


What is cube dimension? : sql server analysis services, ssas

998