[dba-SQLServer] triggers question

Julian Felipe Castrillon Trejos JFK at puj.edu.co
Thu Sep 16 18:57:05 CDT 2004


thank´s for your answer, but i have another question, what happen if i updated only the field3 the value from the fields 1 and 2 is stored in the deleted table too?? 
 
the deleted table only store the values from the updated fields or the entire row?? if it´s not how can i get the field1 value??
 
i hope you can help me, thank you for your quick answer.
 
PD:sorry about the english
 
--------------------------------------------- 
Julian Castrillon T 
Ingeniero de sistemas y computacion
Analista, IDA Ltda 
Ingenieria y desarrollo aplicados 
--------------------------------------------- 
Jesus save, but only Buda 
made incremental backups

________________________________

De: dba-sqlserver-bounces at databaseadvisors.com en nombre de John Maxwell @ London City
Enviado el: mié 15/09/2004 10:58
Para: 'dba-sqlserver at databaseadvisors.com'
Asunto: RE: [dba-SQLServer] triggers question



Hello Julian,

new to sql server so as always happy to be corrected.

However:

In your trigger you can refer to the deleted table
(which contains all the records which have been updated by the event  which
fired the trigger)
and join to your second table on field1 to perform your update.

Have to admit I have not used this myself but think it is the way to go.


Hope this helps

Regards

john


-----Original Message-----
From: dba-sqlserver-bounces at databaseadvisors.com
[mailto:dba-sqlserver-bounces at databaseadvisors.com]On Behalf Of Julian
Felipe Castrillon Trejos
Sent: 14 September 2004 23:15
To: dba-sqlserver at databaseadvisors.com
Subject: [dba-SQLServer] triggers question


hello eveybody i have a question i hope you can help me answer

i'm working with SQL server 2000 and i'm making  an update trigger in a
database.

the thing is, i have two tables and i want to be sure both of then have the
same data, when the principal table is updated that update must be made in
the secondary table but i have a problem, in the principal table there are
several rows with the same value in the field to be updated so i don't
really now witch particular rows was afected in order to make the update in
the secondary table, here is an example

field1    field2   field3
1            x        4
2            y        4
3            z        4
4            w        4
5            u        4
6            c        4

both of the tables have the same data, when i change the value 4 from the
principal table in the field3 in the first row (1   x   4) i want the update
trigger to change the same row in the secundary table but how can i identify
that row in the secondary table if the trigger only give me the value 4 and
the new value for that field and all of the rows have the same 4 in the
field3 so i don't know whitch of the rows was the one updated. i want to
know if there is a way to ask the trigger for the number of the row affected
or somethin like that or if there is a way extract the value from the field1
witch is unique and it could identify exactly one row.

thank you for your help


PD:sorry about the english.

---------------------------------------------
Julian Castrillon T
Ingeniero de sistemas y computacion
Analista, IDA Ltda
Ingenieria y desarrollo aplicados
---------------------------------------------
Jesus save, but only Buda
made incremental backups
_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com


The contents of this email and any attachments are sent for the personal attention
of the addressee(s) only and may be confidential.  If you are not the intended
addressee, any use, disclosure or copying of this email and any attachments is
unauthorised - please notify the sender by return and delete the message.  Any
representations or commitments expressed in this email are subject to contract.

ntl Group Limited

_______________________________________________
dba-SQLServer mailing list
dba-SQLServer at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/dba-sqlserver
http://www.databaseadvisors.com





More information about the dba-SQLServer mailing list