Re: Modifying Primary Key Values
From: Hugo Kornelis (hugo_at_pe_NO_rFact.in_SPAM_fo)
Date: 10/21/04
- Next message: Ian Oldbury: "alter table"
- Previous message: Hugo Kornelis: "Re: Bug in SQL Server 2000?"
- In reply to: ggeshev: "Modifying Primary Key Values"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 21 Oct 2004 11:49:12 +0200
On Thu, 21 Oct 2004 10:30:25 +0300, ggeshev wrote:
>Hello!
>
>Let's suppose I have a table MyTable (A INT PRIMARY KEY, B VARCHAR(20)).
>
>
>
>I send an UPDATE script to sql server.
>
>In this script I modify the A column /the primary key/.
>
>In an AFTER UPDATE TRIGGER I would like by analyzing "inserted" and
> "deleted" virtual tables to understand which row from "inserted"
>corresponds to which row in "deleted".
>
>You understand that I cannot rely for that purpose on the A column /the
>primary key/ because values in it are changed.
>
>How can I make the true correspondence between "new" and "old" rows?
>
>
>
>Thank you!
>
Hi ggeshev,
The only reliable way to do this is to use a combination of other columns
in the same table; this combination should also be unique and the columns
should not be updated as well in the same statement.
If you have no other unique column (or unique combination of columns) or
if that column(s) is updated as well, you're out of luck. You could try to
get a best match based on comparison of all other columns in the table,
but you can never be completely sure that you are correct.
Best, Hugo
-- (Remove _NO_ and _SPAM_ to get my e-mail address)
- Next message: Ian Oldbury: "alter table"
- Previous message: Hugo Kornelis: "Re: Bug in SQL Server 2000?"
- In reply to: ggeshev: "Modifying Primary Key Values"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|