sql - Update trigger Error -
sql - Update trigger Error -
i trying perform update on table has next update trigger getting next error:
subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression.
here trigger...
if value of photoratingid set null deletes records table
if update(photoratingid) begin if (select photoratingid inserted) null begin delete mbr_media_approval_primary deleted, mbr_media_approval_primary deleted.mbrid = mbr_media_approval_primary.mbrid end end
all tables contain unique id 'mbrid'
your select photoratingid inserted
returns more 1 row, error message says. hence is null
comparing cannot work. can transform more or less imperative approach set based approach this:
if update(photoratingid) begin delete map mbr_media_approval_primary map bring together deleted d on d.mbrid=map.mbrid bring together inserted on i.mbrid=d.mbrid i.photoratingid null end
sql sql-server-2008
Comments
Post a Comment