Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:50:18+00:00 2026-06-12T23:50:18+00:00

I’m not sure how to make this happen. We’re debugging an issue and we

  • 0

I’m not sure how to make this happen. We’re debugging an issue and we need to know if it’s possible for @@Error to be non-zero if the insert succeeds. We have a stored procedure that exits if @Error <> 0. And if we knew the answer to this, that would help. Anyone know?

The code is below. We want to know if it’s possible to get to the goto statement if the insert succeeded.

    -- This happened
    insert into Workflow
    (SubID, ProcessID, LineID, ReadTime)
    values
    (@sub_id, @proc_id, @line_id, @read_time)

    set @error = @@Error
    set @insertedWorkflowId = SCOPE_IDENTITY()
    if @error <> 0 
    begin
        set @error_desc = 'insert into tw_workflow'
        goto ERROR_EXIT
    end

    -- This didn't happen
    INSERT INTO Master.WorkflowEventProcessing (WorkflowId, SubId, ReadTime, ProcessId, LineId) VALUES (@insertedWorkflowId, @sub_id, @read_time, @proc_id, @line_id)
    INSERT INTO Master.ProcessLogging (ProcessCode, WorkflowId, SubId, EventTime) VALUES (10, @insertedWorkflowId, @sub_id, GETDATE())

EDIT

Maybe a better way to say what’s wrong is this: The first insert happened but the last two didn’t. How is that possible? Maybe the last two inserts simply just failed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:50:19+00:00Added an answer on June 12, 2026 at 11:50 pm

    If this insert succeeds then there will be a non-zero @@rowcount since you’re simply using values (rather than a select...where which could “successfully” insert 0 rows). You could use this to write some debug checks in there, or just include it as part of the routine for good.

    insert into Workflow
    (SubID, ProcessID, LineID, ReadTime)
    values
    (@sub_id, @proc_id, @line_id, @read_time)
    
    if @@rowcount = 0 or @@error <> 0 -- Problems!
    

    UPDATE

    If a trigger fires on insert, an error in the trigger with severity of:

    • < 10: will run without a problem, @@error = 0
    • between 11 and 16: insert will succeed, @@error != 0
    • 17, 18: insert will succeed, execution will halt
    • 19 (with log): insert will succeed, execution will halt
    • > 20 (with log): insert will not succeed, execution will halt

    I arrived at this by adding a trigger to the workflow table and testing various values for severity, so I can’t readily say this would be the exact case in all environments:

    alter trigger workflowtrig on workflow after insert as begin
        raiserror(13032, 20, 1) with log -- with log is necessary for severity > 18
    end
    

    Soooo, after that, we have somewhat of an answer to this question:

    Can @@Error be non-Zero on a successful insert?

    Yes…BUT, I’m not sure if there is another chain of events that could lead to this, and I’m not creative enough to put together the tests to prove such. Hopefully someone else knows for sure.

    I know this all isn’t a great answer, but it’s too big for a comment, and I thought it might help!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I need a function that will clean a strings' special characters. I do NOT
Does anyone know how can I replace this 2 symbol below from the string
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on
For some reason, after submitting a string like this Jack’s Spindle from a text
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
In my XML file chapters tag has more chapter tag.i need to display chapters

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.