Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

AFTER UPDATE TRIGGER Expand / Collapse
Author
Message
Posted Friday, May 15, 2009 3:54 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 26, 2013 10:10 AM
Points: 9, 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
Post #717733
Posted Friday, May 15, 2009 6:19 AM


SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, September 11, 2014 11:25 AM
Points: 620, Visits: 865
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
Post #717794
Posted Friday, May 15, 2009 7:36 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, March 26, 2013 10:10 AM
Points: 9, Visits: 31
Lovely

Thank You
Post #717895
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse