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 message in Stored procedure

Error message in Stored procedure

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelptutorial
3 Posts 3 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.
  • I Offline
    I Offline
    IamAmit
    wrote on last edited by
    #1

    Hello friends, I want to display error message if any error occurs while executing my stored procedure(for debugging purposes). How to display an error message in stored procedure (I am using sql server 2005) Thanks

    L T 2 Replies Last reply
    0
    • I IamAmit

      Hello friends, I want to display error message if any error occurs while executing my stored procedure(for debugging purposes). How to display an error message in stored procedure (I am using sql server 2005) Thanks

      L Offline
      L Offline
      leoinfo
      wrote on last edited by
      #2

      For debuging purposes, you can add after each (SELECT, INSERT, UPDATE, DELETE, EXECUTE ...) command something like this:

      IF @@ERROR <> 0
      PRINT 'Insert into MyTable failed'

      1 Reply Last reply
      0
      • I IamAmit

        Hello friends, I want to display error message if any error occurs while executing my stored procedure(for debugging purposes). How to display an error message in stored procedure (I am using sql server 2005) Thanks

        T Offline
        T Offline
        TheFM234
        wrote on last edited by
        #3

        Raiserror('Message', 16, 1)

        The above message will show up like an error thrown by the server. It'll get caught by try/catch blocks.

        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