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 8837079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:38:12+00:00 2026-06-14T09:38:12+00:00

I have the below trigger: CREATE Trigger instructor_expertise on CourseSections After Insert As Begin

  • 0

I have the below trigger:

  CREATE Trigger instructor_expertise on CourseSections
     After Insert
     As Begin
     ......

     If (Not Exists(Select AreaName From AreasOfInstructor Where (InstructorNo = @InstructorNo AND AreaName = @AreaName))) 
     Begin 
     RAISERROR('Course not in instructors expertise', 16, 1)
     rollback transaction  
     End
     GO

My question is, does ‘rollback transaction’ remove the row?
What if it’s ‘For Insert’ instead, does ‘rollback transaction’ remove the row in that case?

Thanks!!!

  • 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-14T09:38:13+00:00Added an answer on June 14, 2026 at 9:38 am

    Your INSERT statement always runs in a transaction – either you’ve explicitly defined one, or if not, then SQL Server will use an implicit transaction.

    You’re inserting one (or multiple) row into your table. Then – still inside the transaction – the AFTER INSERT trigger runs and checks certain conditions – typically using the Inserted pseudo table available inside the trigger, which contains the rows that have been inserted.

    If you call ROLLBACK TRANSACTION in your trigger, then yes – your transaction, with everything it’s been doing, is rolled back and it’s as if that INSERT never happened – nothing shows up in your database table.

    Also: FOR INSERT is the same as AFTER INSERT in SQL Server – the trigger is executed after the INSERT statement has done its job.

    One thing to keep in mind (which a lot of programmers get wrong): the trigger is fired once per statement – NOT once per row! So if you insert 20 rows at once, the trigger is fired once and the Inserted pseudo table inside the trigger contains 20 rows. You need to take that into account when writing the trigger – you’re not always dealing with just a single row being inserted!

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

Sidebar

Related Questions

I have below trigger ALTER TRIGGER [dbo].[DeleteUserData] ON [dbo].[site_users] AFTER DELETE AS BEGIN SET
I have a trigger that looks like below: create trigger theTrig insert on table_A
I have some problem executing the trigger below: CREATE OR REPLACE TRIGGER AFTERINSERTCREATEBILL AFTER
I have a table trigger like below: CREATE OR REPLACE TRIGGER PAT_BUR_DOB_TRG BEFORE UPDATE
I have below string String str=select * from m_menus; select * from m_roles; I
I have one question regarding trigger. The scenario is like this Create Procedure begin
Hi i'm trying to create below trigger CREATE TRIGGER TRIGBEFORE INSERT ON employee FOR
When I try create a trigger as given below, CREATE TRIGGER FiscalYearTable1_bi BEFORE INSERT
I have a statement level trigger that fires whenever INSERT UPDATE or DELETE operations
I have this trigger procedure CASE_A as UPDATE table1 SET field1 = (SELECT bus

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.