GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Database  >  SQL Server
Go To First  |  Previous Question  |  Next Question 
 SQL Server  |  Question 90 of 94    Print  
How is the error handling in stored proc of T-SQL ?
1 How is the error handling in stored proc of T-SQL
2 What is clustered index and non-clustered index? How many clustered indexes and non-clustered indexes can be created in one table?
3-what is disconnected mode?



  
Total Answers and Comments: 4 Last Update: September 02, 2008     Asked by: ajay_shu007 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 21, 2008 04:56:22   #1  
sunilsoni30 Member Since: December 2007   Contribution: 4    

RE: How is the error handling in stored proc of T-SQL ?
error<> o
 
Is this answer useful? Yes | No
July 01, 2008 13:42:57   #2  
seemu123 Member Since: May 2008   Contribution: 7    

RE: How is the error handling in stored proc of T-SQL ?

In SQL Server 2000
 We can check by @@Error<>0 i.e. error.
ex:
     IF @@Error<>0
          BEGIN

             ROLLBACK TRANSACTIOn

             RETURN

          END

     ELSE

          BEGIN

             COMMIT TRANSACTION

             RETURN

          END

Note: You need to check @@Error at every DML statement and since it is Global Variable, So it reset every time.

In SQL Server 2005
We can check by using try catch block
ex:

BEGIN TRY

BEGIN TRANSACTION
/*statement*/

COMMIT TRANSACTION

END TRY

BEGIN CATCH

IF @@TRANCOUNT>0

ROLLBACK TRAN

END CATCH

Note: You can check the following functions in catch block
a)ERROR_NUMBER() returns no of the error
b)ERROR_SEVERITY() returns severity of the error
c)ERROR_STATE() returns error state no
d)ERROR_PROCEDURE() returns name of stored procedure
e)ERROR_LINE() returns line no.
f)ERROR_Message() returns the complete text of the message


 
Is this answer useful? Yes | No
July 17, 2008 13:12:16   #3  
suaveshiva Member Since: July 2008   Contribution: 1    

RE: How is the error handling in stored proc of T-SQL ?
Abt Clustered indexes:
V can hav only one clustered index in a table, by default primary key is termed as  clustered index.
V can have 249 non-clustered indexes in a table.

 
Is this answer useful? Yes | No
September 02, 2008 08:27:43   #4  
yemshivakumar Member Since: September 2008   Contribution: 1    

RE: How is the error handling in stored proc of T-SQL ?
We can use @@ERROR keyword for handling errors.  RAISEERROR also we can use.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape