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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:05:19+00:00 2026-05-13T17:05:19+00:00

I have an on update trigger in SQL Server 2008. I only need to

  • 0

I have an on update trigger in SQL Server 2008. I only need to perform the trigger action if certain columns have been modified. Thus I’d like to check what has changed.

T-SQL offers an “if update( columnName )” construct. However, if many rows have been updated and only a single one of them has the particular column value changed “if update()” will have to return true. This’ll make me perform the trigger action for far more rows than required.

So instead of using “if update()” I thought I’d just join the virtual deleted and inserted tables (the rows before and after update) and compare the relevant columns myself. However, how can I join the two tables? I cannot use the table’s primary key since that may have been modified by the update. The only thing I can think of is joining by row_number(), i.e. implicit table ordering. This feels very wrong though and I don’t know whether SQL Server actually offers any guarantuees that rows in inserted are ordered the same as in deleted.

  • 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-13T17:05:20+00:00Added an answer on May 13, 2026 at 5:05 pm

    With your design (that allows changing primary keys) it seems very hard to build a consistent logic.

    Say, you have this table:

    id   value
    1    2
    2    1
    

    and issue this operation:

    UPDATE  mytable
    SET     id = CASE WHEN id = 1 THEN 2 ELSE 1 END,
            value = CASE WHEN value = 1 THEN 2 ELSE 1 END
    

    which updates both records but leaves the table as this:

    id   value
    2    1
    1    2
    

    , which from relational point of view is similar to not changing the table at all.

    The whole point of the primary keys is that they never change.

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

Sidebar

Ask A Question

Stats

  • Questions 493k
  • Answers 494k
  • 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 You have to import flash.ui.Mouse, and use the fully qualified… May 16, 2026 at 10:54 am
  • Editorial Team
    Editorial Team added an answer Can't comment unless looking at Member model. But Can't we… May 16, 2026 at 10:54 am
  • Editorial Team
    Editorial Team added an answer RIL.dll is available only on phone devices. If your WinMo… May 16, 2026 at 10:54 am

Trending Tags

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

Top Members

Related Questions

I have inherited a SQL Server 2008 database to which calling applications have access
As I have seen, SQL 2008 no longer offers replication over internet in very
I am just trying to think through a process I need where I have:
I have an Entity Framework model that was generated by the Visual Studio 2008
I have a need to monitor a subset of fields on a table and
I have a problem with Updating Form Element Look and Feel under Update Panel
Is it possible to see the DML (SQL Statement) that is being run that
I have this code: <ComboBox Width=100 ItemsSource={Binding FontList} x:Name=fontComboFast> <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate>
I have a script that fetches several web pages and parses the info. (An
I have written a small program using Borland's C++ builder, and along the way,

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.