May 15, 2009 at 3:54 am
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
May 15, 2009 at 6:19 am
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
May 15, 2009 at 7:37 am
Lovely
Thank You
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply