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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. How do you resume next?

How do you resume next?

Scheduled Pinned Locked Moved Database
sharepointhelpquestioncareer
3 Posts 2 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.
  • K Offline
    K Offline
    kayos592
    wrote on last edited by
    #1

    CREATE TABLE TestTable (Field1 INT) GO DECLARE @Err INT INSERT INTO TestTable (field1) VALUES (9999999999) SELECT @Err = @@Error IF @Err <> 0 BEGIN PRINT 'Im In' INSERT INTO TestTable (field1) VALUES ('1235456') END SELECT * FROM TestTable WHERE field1 = 'ABC' SELECT @Err = @@Error IF @Err <> 0 BEGIN PRINT 'Im In' INSERT INTO TestTable (field1) VALUES ('1235456') END When executing the above code, you will enter the first @Err condition but not the second. Both errors produce the same Severity level so I'm not sure why it resumes on one but not the other. Is there any way to force an SP to resume next?

    -Kay

    C 1 Reply Last reply
    0
    • K kayos592

      CREATE TABLE TestTable (Field1 INT) GO DECLARE @Err INT INSERT INTO TestTable (field1) VALUES (9999999999) SELECT @Err = @@Error IF @Err <> 0 BEGIN PRINT 'Im In' INSERT INTO TestTable (field1) VALUES ('1235456') END SELECT * FROM TestTable WHERE field1 = 'ABC' SELECT @Err = @@Error IF @Err <> 0 BEGIN PRINT 'Im In' INSERT INTO TestTable (field1) VALUES ('1235456') END When executing the above code, you will enter the first @Err condition but not the second. Both errors produce the same Severity level so I'm not sure why it resumes on one but not the other. Is there any way to force an SP to resume next?

      -Kay

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      kayos592 wrote:

      When executing the above code, you will enter the first @Err condition but not the second.

      I don't see where the second condition, a simple SELECT, could fail under normal conditions. It could return an empty result set, but that's about it. What error are you expecting?

      kayos592 wrote:

      Both errors produce the same Severity level so I'm not sure why it resumes on one but not the other.

      I don't see what error the second condition is producing. And I don't know what you mean by "it resumes on one but not the other".


      Upcoming events: * Glasgow: Introduction to AJAX (2nd May), SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

      K 1 Reply Last reply
      0
      • C Colin Angus Mackay

        kayos592 wrote:

        When executing the above code, you will enter the first @Err condition but not the second.

        I don't see where the second condition, a simple SELECT, could fail under normal conditions. It could return an empty result set, but that's about it. What error are you expecting?

        kayos592 wrote:

        Both errors produce the same Severity level so I'm not sure why it resumes on one but not the other.

        I don't see what error the second condition is producing. And I don't know what you mean by "it resumes on one but not the other".


        Upcoming events: * Glasgow: Introduction to AJAX (2nd May), SQL Server 2005 - XML and XML Query Plans, Mock Objects, SQL Server Reporting Services... Never write for other people. Write for yourself, because you have a passion for it. -- Marc Clifton My website

        K Offline
        K Offline
        kayos592
        wrote on last edited by
        #3

        If you execute the attached code in SQL Query analyzer you will see what I'm talking about. Basically, if you try a simple select on an INT field where the where condition is looking for Alpha characters it will give you an error. Simply put, the below code is a simple select which causes an error. Now I know I can check values prior to everything but I want it to continue onto the next record in the event that a simple select causes an error instead of just dying. Please let me know if I should elaborate... CREATE TABLE TestTable (Field1 INT) GO DECLARE @Err INT SELECT * FROM TestTable WHERE field1 = 'ABC' SELECT @Err = @@Error IF @Err <> 0 BEGIN PRINT 'Im In Error Handling number 2' END Now what I mean by "it resumes on one but not the other" is for the first error it will go into the error condition and even execute more of the script, however on the simple select error, it will stop right there and progress no further. Hope that clarifies...

        -Kay

        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