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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T01:48:34+00:00 2026-06-09T01:48:34+00:00

I am quite new to writing SQL triggers and I had one working for

  • 0

I am quite new to writing SQL triggers and I had one working for a while now as desired however now I would like to add a where clause to the trigger so that it only fires if a certain condition is met.

In this particular scenario I want to check and see if ContextDN like '%FA 2012%' and if so then have the trigger fire. Here is my current trigger:

CREATE TRIGGER [dbo].[setAsMoodle]
ON [dbo].[LMS_Section]
For Insert
As
INSERT INTO [dbo].[CUS_LmsSection_LmsProxy] (LMSSectionID, LMSProxyID, LMSSectionCtxDN)
select  SectionID , 'DEE76E47-25E6-459B-9D38-1BCAFA44077A', ContextDN from inserted

Any suggestions on how to go about doing this?

  • 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-09T01:48:35+00:00Added an answer on June 9, 2026 at 1:48 am

    Just put the where on the end of your insert statement

    USE ICS_NET; 
    
    GO 
    CREATE TRIGGER [dbo].[setAsMoodle] 
    ON [dbo].[LMS_Section] 
    For Insert 
    As 
    INSERT INTO [dbo].[CUS_LmsSection_LmsProxy] (LMSSectionID, LMSProxyID, LMSSectionCtxDN) 
    select  SectionID , 'DEE76E47-25E6-459B-9D38-1BCAFA44077A', ContextDN from inserted
    where ContextDN like '%FA 2012%'
    

    The trigger will always fire, but only the rows matching the condition get inserted.

    This is important as the trigger may fire for multiple rows at once for a batch insert so you wouldn’t be able to selectively run it.

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

Sidebar

Related Questions

Iam quite new to functions in SQL and I would like to create a
I'm quite new to sql and I'm having trouble writing this i have a
I am quite new to writing Firefox Add-Ons, still, I got to a point
I am using SQL server 2008 and I'm quite new to writing sql. My
I am quite new to Selenium. Currently i am using selenium driver for writing
Scenario: Quite new to DI and Ninject but would love to master it so
I'm quite new to Java Programming and am writing my first desktop app, this
Hi i m quite new to mvc and i m writing a report which
I'm quite new to that functional programming paradigm, but so far I like it.
I am quite new to Perl, and I am writing a Perl script. A

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.