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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:40:48+00:00 2026-05-27T23:40:48+00:00

I am trying to write an sql trigger that will update another table whenever

  • 0

I am trying to write an sql trigger that will update another table whenever an update is executed. This is actually used to replace replication (replication exists on our production environment but not on dev environment because it causes problems on dev).
I’ve written following trigger to achieve this, but it doesn’t seem to work and I have no idea why. (Also I have no idea how to debug triggers)

USE [AuditQuestionnaireManagerDemo]
GO
/****** Object:  Trigger [dbo].[CatchUpdateUser]    Script Date: 01/04/2012 09:25:40 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:      <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER TRIGGER [dbo].[CatchUpdateUser]
   ON  [dbo].[User]
   FOR UPDATE
AS 
BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;

    update SharedServicesDemo.dbo.[User]
        set SharedServicesDemo.dbo.[User].Username = Username,
            SharedServicesDemo.dbo.[User].PasswordHash = PasswordHash,
            SharedServicesDemo.dbo.[User].Salt = Salt,
            SharedServicesDemo.dbo.[User].PersonGUID = PersonGUID,
            SharedServicesDemo.dbo.[User].OrganizationGUID = OrganizationGUID,
            SharedServicesDemo.dbo.[User].IsDeleted = IsDeleted,
            SharedServicesDemo.dbo.[User].IsActive = IsActive
        where SharedServicesDemo.dbo.[User].GUID = GUID
    SELECT GUID, ID, Username, PasswordHash, Salt, PersonGuid, OrganizationGUID, IsDeleted, IsActive From Inserted

END

Would be great if anyone could spot the problem here!

This insert trigger did work with the insert/select combo:

SET IDENTITY_INSERT SharedServicesDemo.dbo.[User] ON
INSERT INTO SharedServicesDemo.dbo.[User] (GUID, ID, Username, PasswordHash, Salt, PersonGUID, OrganizationGUID, IsDeleted, IsActive)
SELECT GUID, ID, Username, PasswordHash, Salt, PersonGuid, OrganizationGUID, IsDeleted, IsActive From Inserted
SET IDENTITY_INSERT SharedServicesDemo.dbo.[User] OFF
  • 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-27T23:40:49+00:00Added an answer on May 27, 2026 at 11:40 pm

    Your trigger currently does nothing (you got lucky(unlucky?) in that the syntax compiles but does not do what you intend). Try:

    update SharedServicesDemo.dbo.[User] 
    set  SharedServicesDemo.dbo.[User].Username = i.Username,
        SharedServicesDemo.dbo.[User].PasswordHash = i.PasswordHash,
        SharedServicesDemo.dbo.[User].Salt = i.Salt,
        SharedServicesDemo.dbo.[User].PersonGUID = i.PersonGUID,
        SharedServicesDemo.dbo.[User].OrganizationGUID = i.OrganizationGUID,
        SharedServicesDemo.dbo.[User].IsDeleted = i.IsDeleted,
        SharedServicesDemo.dbo.[User].IsActive = i.IsActive
    From  SharedServicesDemo.dbo.[User]
    inner join inserted i ON SharedServicesDemo.dbo.[User].GUID = i.GUID
    

    Ref.: UPDATE

    [Might need to alias the second instance of SharedServicesDemo.dbo.[User] …]

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

Sidebar

Related Questions

Im trying to write an SQL query that will check in the table ‘persons’
I'm trying to write some SQL that will delete files of type '.7z' that
I'm trying to write a SQL script that inserts 2 rows into a table
I'm trying to write a stored procedure in SQL that will : Make a
I am trying to write a SQL query that returns rows from a table
I'm trying to write an sql function in Postgresql that will parse a file
I am trying to write a trigger function in PostgreSQL 8.2 that will dynamically
I'm trying to write an SQL query that will gather certain data in one
I'm trying to write a sql statement that will insert data given a few
I'm trying to write sql that produces the desired result from the data below.

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.