SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


AFTER UPDATE TRIGGER


AFTER UPDATE TRIGGER

Author
Message
debbie.coates
debbie.coates
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 31
Can anyone tell me if its possible to do this

I have a table called BankDtails with the following fields
ProjectID
AccountName
BankBuildingSocietyName
BankAddress
BankPostcode
BankSortCode
BankAccountNumber
RollRefNumber

The field ProjectID will be something like 10024

In the same table I may also have a record with a ProjectID of 99910024

the second record will always be proceeded with a 999

Is there a way that i can create an after update trigger that will detect if there is a corresponding record with a 999 prefix and update that record?

I would appreciate any help on this.

Thank You
RP_DBA
RP_DBA
SSC Eights!
SSC Eights! (947 reputation)SSC Eights! (947 reputation)SSC Eights! (947 reputation)SSC Eights! (947 reputation)SSC Eights! (947 reputation)SSC Eights! (947 reputation)SSC Eights! (947 reputation)SSC Eights! (947 reputation)

Group: General Forum Members
Points: 947 Visits: 1070
debbie.coates (5/15/2009)

Is there a way that i can create an after update trigger that will detect if there is a corresponding record with a 999 prefix and update that record?


Try something like this in your trigger

update bd
set AccountName = ins.AccountName
, BankBuildingSocietyName = ins.BankBuildingSocietyName
, BankAddress = ins.BankAddress
, BankPostcode = ins.BankPostcode
, BankSortCode = ins.BankSortCode
, BankAccountNumber = ins.BankAccountNumber
, RollRefNumber = ins.RollRefNumber
from BankDtails bd
inner join inserted ins on db.ProjectID = convert(int,'999' + convert(varchar,ins.ProjectID))

I'm assuming that projectid is an int, if not you won't need the convert statements in the join.

_____________________________________________________________________
- Nate

@nate_hughes
debbie.coates
debbie.coates
Grasshopper
Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)Grasshopper (11 reputation)

Group: General Forum Members
Points: 11 Visits: 31
Lovely

Thank You
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search