Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 7,2000
»
T-SQL
»
AFTER UPDATE TRIGGER
AFTER UPDATE TRIGGER
Rate Topic
Display Mode
Topic Options
Author
Message
debbie.coates
debbie.coates
Posted Friday, May 15, 2009 3:54 AM
Forum 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
RP_DBA
RP_DBA
Posted Friday, May 15, 2009 6:19 AM
Mr or Mrs. 500
Group: General Forum Members
Last Login: Wednesday, May 15, 2013 12:31 PM
Points: 580,
Visits: 814
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
debbie.coates
debbie.coates
Posted Friday, May 15, 2009 7:36 AM
Forum 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 »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.