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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:22:20+00:00 2026-05-29T07:22:20+00:00

I want a SQL trigger to fire when a table is updated. I have

  • 0

I want a SQL trigger to fire when a table is updated. I have a table called SimActivation and a stored procedure called spUpdateMnpDate that takes two parameters, msisdn(varchar) and date(datetime).

When the SimActivation table is updated I want to call the procedure with the new values.

Here is what I got at the moment, after changing it back and forth:

USE StoreSale;
GO
CREATE TRIGGER dbo.tSyncMnpDate
ON [dbo].[SimActivation]
AFTER UPDATE
AS      
    DECLARE @date datetime
    DECLARE @msisdn varchar(10)
    SET @date = (select ProcessDate from inserted)
    SET @msisdn = (select Msisdn from inserted)
    EXEC [spUpdateMnpDate] 
    @msisdn, @date;

GO

Can anyone point me in the right direction?

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-05-29T07:22:21+00:00Added an answer on May 29, 2026 at 7:22 am

    The problem you have is that a trigger will fire when one or more rows have been updated. At the moment you are assuming your trigger will fire for each row, which is not the case in SQL Server.

    If the stored procedure you are trying to call is fairly simple I’d pull the code out of there and in to the trigger. But remember you are working with sets of changed rows (even if the change is to only one row) so you have to write your SQL accordingly.

    EDIT: I assume your procedure is updating a date where the PK is equal to @msisdn, if so you can do this in your trigger:

    UPDATE Your_Table
    SET Your_Table.ProcessDate = inserted.ProcessDate
    FROM Your_table INNER JOIN inerted ON Your_Table.Msisdn = inserted.Msisdn
    

    Joining the tables ensures it will work for one or many updated rows.

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

Sidebar

Related Questions

I have a table in a SQL Server 2005 database with a trigger that
I have two sql tables called scan_sc and rescan_rsc . The scan table looks
Hi i want to call a stored procedure or fire a trigger when a
I want to have an instead of delete trigger so that I can get
I have a trigger in SQL Server 2005 that is used to track audit
I have a SQL Server 2008 database that has a Trigger. This trigger is
With sql Server 2005. I have declared a trigger that get fired AFTER INSERT,
I have a sql trigger that is used to audit my database tables. Data
I have two tables, tableA and tableB. I want to set a trigger. Once
I need to alter a trigger in sql server 2005 and I want to

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.