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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:49:34+00:00 2026-05-10T16:49:34+00:00

In SQL Server 2005, is there a way for a trigger to find out

  • 0

In SQL Server 2005, is there a way for a trigger to find out what object is responsible for firing the trigger? I would like to use this to disable the trigger for one stored procedure.

Is there any other way to disable the trigger only for the current transaction? I could use the following code, but if I’m not mistaken, it would affect concurrent transactions as well – which would be a bad thing.

DISABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL } ON { object_name | DATABASE | ALL SERVER } [ ; ]  ENABLE TRIGGER { [ schema_name . ] trigger_name [ ,...n ] | ALL } ON { object_name | DATABASE | ALL SERVER } [ ; ] 

If possible, I would like to avoid the technique of having a ‘NoTrigger’ field in my table and doing a NoTrigger = null, because I would like to keep the table as small as possible.

The reason I would like to avoid the trigger is because it contains logic that is important for manual updates to the table, but my stored procedure will take care of this logic. Because this will be a highly used procedure, I want it to be fast.

Triggers impose additional overhead on the server because they initiate an implicit transaction. As soon as a trigger is executed, a new implicit transaction is started, and any data retrieval within a transaction will hold locks on affected tables.

From: http://searchsqlserver.techtarget.com/tip/1,289483,sid87_gci1170220,00.html#trigger

  • 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. 2026-05-10T16:49:34+00:00Added an answer on May 10, 2026 at 4:49 pm

    I just saw this article recently highlighted on the SQL Server Central newsletter and it appears to offer a way which you may find useful using the Context_Info on the connection:

    http://www.mssqltips.com/tip.asp?tip=1591


    EDIT by Terrapin:

    The above link includes the following code:

    USE AdventureWorks;   GO   -- creating the table in AdventureWorks database   IF OBJECT_ID('dbo.Table1') IS NOT NULL   DROP TABLE dbo.Table1   GO   CREATE TABLE dbo.Table1(ID INT)   GO    -- Creating a trigger   CREATE TRIGGER TR_Test ON dbo.Table1 FOR INSERT,UPDATE,DELETE   AS   DECLARE @Cinfo VARBINARY(128)   SELECT @Cinfo = Context_Info()   IF @Cinfo = 0x55555   RETURN   PRINT 'Trigger Executed'   -- Actual code goes here   -- For simplicity, I did not include any code   GO   

    If you want to prevent the trigger from being executed you can do the following:

    SET Context_Info 0x55555  INSERT dbo.Table1 VALUES(100) 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 140k
  • Answers 140k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer check the following topic it's very useful: codeproject May 12, 2026 at 7:55 am
  • Editorial Team
    Editorial Team added an answer Yes you can, but with very large of restrictions. Some… May 12, 2026 at 7:55 am
  • Editorial Team
    Editorial Team added an answer Could you use a ListView control with the View property… May 12, 2026 at 7:54 am

Related Questions

Is there a way around this in SQL Server 2005? (It bugs me, and
I'm just wondering if there's a better way of doing this in SQL Server
How do you track/manage your stored procedures, views, and functions in SQL Server? I'd
I have the same problem as described in this question , but there it's

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.