Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Triggers/Multirow Update

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-10-14 : 22:26:12
Melanie writes "I would like to know how I can make the following trigger update multiple rows instead of just one. I'm pretty new to this so any other suggestions would be greatly appreciated.

CREATE TRIGGER update_acct ON dbo.rd_proj_no
FOR UPDATE
AS

Begin Transaction

declare @num_rows int, @error_no int
select @num_rows=@@rowcount

if @num_rows=0
Return

if update(active)

Begin
update atc_rd_alloc
set active = i.active
from atc_rd_alloc a, inserted i, deleted d
where a.active = d.active
End

Select @error_no = @@error


If @error_no <> 0
GoTo ErrorHandler



ErrorHandler:
Rollback Transaction
Return

Commit Transaction


Go
"
   

- Advertisement -