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

  • SEARCH
  • Home
  • 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 8763535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:48:04+00:00 2026-06-13T15:48:04+00:00

good afternoon, I have a problem with the rollback … Treger initially was using

  • 0

good afternoon,
I have a problem with the rollback … Treger initially was using to call the procedure and the procedure is triggered rollback but it is …
Now I’m trying to do the rollback from trigger nor …

attached the code and the error

Thanks for your help

USE [Desarrollo_Pruebas]
GO
/****** Object:  Trigger [dbo].[Prueba_tre]    Script Date: 10/30/2012 17:02:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

ALTER TRIGGER [dbo].[Prueba_tre] 
   ON  [dbo].[Cliente]
    FOR INSERT
AS 
BEGIN

 SET NOCOUNT ON;

begin try
    BEGIN TRAN t1
    SAVE TRAN t1
    INSERT INTO Articulo (Articulo_Codigo, Articulo_Descripcion, Valor_unitario, Categoria_id, msg) VALUES (1040,'EURECA',15000,5,'')
    COMMIT 
    --raiserror ('Test error',16,1)
end try

begin catch
    ROLLBACK TRAN t1
    SELECT    ERROR_NUMBER() AS ERROR_NUMBER, ERROR_MESSAGE() AS ERROR_MESSAGE;
end catch

--SET NOCOUNT ON;
--exec Prueba CLIENTE_ID;

END

Msg 3931, Level 16, State 1, Procedure Prueba_tre, Line 21
The current transaction cannot be committed and cannot be rolled back to a savepoint. Roll back the entire transaction.

THE TABLE IS

the idea is that when I insert into customers products with an insert update ..
at the end of this transaction need to return from the console

CREATE TABLE Articulo
(
   Articulo_Codigo int not null primary key
   , Articulo_Descripcion varchar (100)
   , Valor_unitario int
   , Categoria_Id int not null constraint fk_Categoria references Categoria (CATEGORIA_ID)
)

CREATE TABLE Cliente
(
   CLIENTE_ID int not null primary key
   , CLIENTE_PRIMER_NOMBRE varchar(50)
   , CLIENTE_SEGUNDO_NOMBRE varchar(50)
   , CLIENTE_PRIMER_APELLI varchar(50)
   , CLIENTE_SEGUNDO_APELLI varchar(50)
   , CLIENTE_DIRECCION varchar(90)
   , CLIENTE_TELEFONO int
   , CLIENTE_CIUDAD varchar(50)
)
  • 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-13T15:48:06+00:00Added an answer on June 13, 2026 at 3:48 pm

    Сontinue using procedure. I think you just don’t check Exception handling and nested transactions.

    CREATE PROCEDURE [dbo].[Prueba_tre]
    AS
    BEGIN
      SET NOCOUNT ON;
      declare @trancount int;
      set @trancount = @@trancount;
      begin try
        if @trancount = 0
          begin transaction
        else
          save transaction t1
    
        INSERT INTO Articulo (Articulo_Codigo, Articulo_Descripcion, Valor_unitario, Categoria_id, msg) VALUES (1040,'EURECA',15000,5,'')
        if @trancount = 0 
          commit; 
      end try
      begin catch
        declare @error int, @message varchar(4000 ), @xstate int;
        select @error = ERROR_NUMBER(),
        @message = ERROR_MESSAGE(),
        @xstate = XACT_STATE();
       if @xstate = -1
         rollback;
       if @xstate = 1 and @trancount = 0
         rollback
       if @xstate = 1 and @trancount > 0
         rollback transaction t1
       raiserror ('t1: %d: %s' , 16, 1, @error, @message)
      end catch
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Very good afternoon to all, The problem I have now is that I can
Good afternoon, I have encountered a problem to choose from two connection strings using
Good afternoon, I'm learning about using RegEx's in Ruby, and have hit a point
Good morning / afternoon, I have a problem with LDAP connector, when I use
Good afternoon. I am starting with Visual c++ and I have a compilation problem
Good morning/afternoon, Not so much a problem but more of a query. If I
Good afternoon, I have a listview filled using linqdatasource + entity framework iqueryable query.
Good afternoon. I have the following problem, the end of the attribute value <c:
Good afternoon to all, I have this scenario: I am using SQL Server 'BulkInsert'
Good afternoon, I am new to EC2 and have been trying to mount an

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.