![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
#3
| |||
| |||
|
|
Hi, Does anyone know of a simple way to do this? I want to create an insert trigger for a table and if the record already exists based on some criteria, I want to update the table with the values that are passed in via the insert trigger without having to use all the 'set' statements for each field (so if we add fields in the future I won't have to update the trigger). In other words, I want the trigger code to look something like this: if exists (select * from TableA where Fld1 = inserted.Fld1) then //don't do insert, do an update instead (would i want to rollback here? and will I have access to the 'inserted' table still?) Update TableA Set TableA.<all the fields> = Inserted.<all the fields where Fld1 = inserted.Fld1 end if Any help or ideas would be appreciated. Thanks, Teresa |
#4
| |||
| |||
|
|
Hi, Does anyone know of a simple way to do this? I want to create an insert trigger for a table and if the record already exists based on some criteria, I want to update the table with the values that are passed in via the insert trigger without having to use all the 'set' statements for each field (so if we add fields in the future I won't have to update the trigger). In other words, I want the trigger code to look something like this: if exists (select * from TableA where Fld1 = inserted.Fld1) then //don't do insert, do an update instead (would i want to rollback here? and will I have access to the 'inserted' table still?) Update TableA Set TableA.<all the fields> = Inserted.<all the fields where Fld1 = inserted.Fld1 end if Any help or ideas would be appreciated. Thanks, Teresa |
![]() |
| Thread Tools | |
| Display Modes | |
| |