sql - Will inserted and deleted record count always be equal in an update trigger? -
i have update trigger next code:
declare @numrows int select @numrows = @@rowcount if @numrows <> 1 homecoming
in cases @numrows returns 0 though row count 1. think it's because select resets row count? anyway, i'm replacing this:
set @numrows = (select count(*) inserted)
later in trigger i'm using both inserted , deleted table records. row counts inserted , deleted equal, or need check them separately?
i cant comment on merge steve has in answer, if update run on table
update tablea set column1 = "abc" column1 = "def"
and update trigger exists on tablea, when trigger fires, yes, count of records in each of inserted & deleted tables same, , equal number of rows affected update statement run.
sql sql-server tsql
No comments:
Post a Comment