YRB

Discover innovative solutions, best practices, and cutting-edge technologies in enterprise architecture

Tuesday, January 24, 2012

Ideal SQL Query For Handling Error & Transcation in MS SQL



BEGIN TRY

BEGIN TRAN

--put queries here

COMMIT;

END TRY
BEGIN CATCH
IF @@TRANCOUNT>0
BEGIN
SELECT @@ERROR,ERROR_MESSAGE ( )
ROLLBACK;
END
END CATCH


any one can use above code to manage transaction as well as error handling in sql server.
at January 24, 2012 No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Search This Blog

Blog Archive

  • ►  2024 (7)
    • ►  August (5)
    • ►  July (2)
  • ▼  2012 (1)
    • ▼  January (1)
      • Ideal SQL Query For Handling Error & Transcation i...
  • ►  2011 (4)
    • ►  May (1)
    • ►  April (3)
  • ►  2010 (14)
    • ►  December (2)
    • ►  May (1)
    • ►  April (1)
    • ►  February (5)
    • ►  January (5)
  • ►  2009 (71)
    • ►  December (7)
    • ►  November (13)
    • ►  October (9)
    • ►  September (6)
    • ►  August (7)
    • ►  July (4)
    • ►  June (12)
    • ►  May (3)
    • ►  April (10)

Featured Post

Mastering Azure SQL: A Comprehensive Guide

  Introduction In the modern digital landscape, data is the lifeblood of businesses. Managing and leveraging this data effectively is crucia...

Powered by Blogger.