Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Error trapping in SQL Server 2005 [modified]

Error trapping in SQL Server 2005 [modified]

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelp
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    vanikanc
    wrote on last edited by
    #1

    Hello, I have not really coded for error trapping the past since the applications were not that big. Currently, the app being worked on is huge with multiple phases development. I wanted to find out the best practices for error trapping, some simple forms and some more complex ones. I need to start using them It is also ok, to write them to the database tables if possible. I know I can google this as well but some times it takes a longer amount of time to find the correct link/article. Thank you for your time!

    modified on Monday, August 1, 2011 3:43 PM

    J L M T 4 Replies Last reply
    0
    • V vanikanc

      Hello, I have not really coded for error trapping the past since the applications were not that big. Currently, the app being worked on is huge with multiple phases development. I wanted to find out the best practices for error trapping, some simple forms and some more complex ones. I need to start using them It is also ok, to write them to the database tables if possible. I know I can google this as well but some times it takes a longer amount of time to find the correct link/article. Thank you for your time!

      modified on Monday, August 1, 2011 3:43 PM

      J Offline
      J Offline
      jschell
      wrote on last edited by
      #2

      There is no way to trap everything. And it is non-sensical as well. So you need to determine some actual implementation cases where it is reasonable.

      vanikanc wrote:

      It is also ok, to write them to the database tables if possible.

      Still depends on what you mean by error. It is certainly possible for some cases. Also why is this just a database relevant question? If the system is large then there will be other parts of the system which will fail in relation to the database. For example bouncing the database is very likely to cause ripple failures in a 24x7 system unless those other systems are specifically designed to deal with that.

      V 1 Reply Last reply
      0
      • J jschell

        There is no way to trap everything. And it is non-sensical as well. So you need to determine some actual implementation cases where it is reasonable.

        vanikanc wrote:

        It is also ok, to write them to the database tables if possible.

        Still depends on what you mean by error. It is certainly possible for some cases. Also why is this just a database relevant question? If the system is large then there will be other parts of the system which will fail in relation to the database. For example bouncing the database is very likely to cause ripple failures in a 24x7 system unless those other systems are specifically designed to deal with that.

        V Offline
        V Offline
        vanikanc
        wrote on last edited by
        #3

        Even if there are some scenarios i would like to trap for, which syntax would I use? Like C# has a Try, Catch, Finally block I use for displaying som error messgaes.

        J 1 Reply Last reply
        0
        • V vanikanc

          Hello, I have not really coded for error trapping the past since the applications were not that big. Currently, the app being worked on is huge with multiple phases development. I wanted to find out the best practices for error trapping, some simple forms and some more complex ones. I need to start using them It is also ok, to write them to the database tables if possible. I know I can google this as well but some times it takes a longer amount of time to find the correct link/article. Thank you for your time!

          modified on Monday, August 1, 2011 3:43 PM

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          BEGIN TRY
          -- Write code that can throw error
          END TRY
          BEGIN CATCH
          -- Catch error
          END CATCH

          1 Reply Last reply
          0
          • V vanikanc

            Hello, I have not really coded for error trapping the past since the applications were not that big. Currently, the app being worked on is huge with multiple phases development. I wanted to find out the best practices for error trapping, some simple forms and some more complex ones. I need to start using them It is also ok, to write them to the database tables if possible. I know I can google this as well but some times it takes a longer amount of time to find the correct link/article. Thank you for your time!

            modified on Monday, August 1, 2011 3:43 PM

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            All the data validation is done in the business layer so the data hitting the database is clean and I write perfect stored procedures so I don't need error trapping in the database. Once a procedure is coded it generally does not break unless there is a change in structure. The few cases where I can identify this may be prevalent is where I use try/catch structures. I do have a trigger based logging system but that is not error trapping.

            Never underestimate the power of human stupidity RAH

            1 Reply Last reply
            0
            • V vanikanc

              Hello, I have not really coded for error trapping the past since the applications were not that big. Currently, the app being worked on is huge with multiple phases development. I wanted to find out the best practices for error trapping, some simple forms and some more complex ones. I need to start using them It is also ok, to write them to the database tables if possible. I know I can google this as well but some times it takes a longer amount of time to find the correct link/article. Thank you for your time!

              modified on Monday, August 1, 2011 3:43 PM

              T Offline
              T Offline
              thatraja
              wrote on last edited by
              #6

              vanikanc wrote:

              I know I can google this as well but some times it takes a longer amount of time to find the correct link/article.

              Then give a shot in CP. Overview of Error Handling in SQL Server 2005[^] A Closer Look Inside RAISERROR - SQLServer 2005 [^]

              thatraja


              **My Tip/Tricks
              My Dad had a Heart Attack on this day so don't...
              **

              1 Reply Last reply
              0
              • V vanikanc

                Even if there are some scenarios i would like to trap for, which syntax would I use? Like C# has a Try, Catch, Finally block I use for displaying som error messgaes.

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #7

                SQL server has try/catch. But you need to be careful with it. One might think that they could put that in every proc as thus record errors but I am rather certain that in many procs the errors that might occur would be the ones that would be compounded by attempting another write to the database. For example a table space error.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups