I have a table where I want to have a trigger on update action:

```
ALTER TRIGGER [dbo].[cmt_update]
ON [dbo].[comments] 
FOR UPDATE
AS 
    DECLARE @Cinfo VARBINARY(128) 

    SELECT @Cinfo = Context_Info() 

    IF @Cinfo = 0x55555 
        RETURN 

    -- insert into syncro requests
    INSERT INTO syncros_requests (db_table_name, db_table_id,  action_type, request_date, syncro_status, syncro_msg, creation_date, usr,  edition_date, usr_edition)  
        SELECT 
            'comments', id, 'U', GETDATE(), 'NS', '', GETDATE(), usr, GETDATE(), usr 
        FROM 
            inserted

    IF (select pendent from deleted) = 0 AND (select pendent from inserted) = 1
    -- insert into syncro requests
    insert into syncros_requests(db_table_name, db_table_id,  action_type, request_date, syncro_status, syncro_msg, creation_date, usr,  edition_date, usr_edition)  
    select 'comments', id,  'D', GETDATE(), 'NS', '', GETDATE(), usr, GETDATE(), usr from inserted

```

The problem is when I update multiple rows at once, it gives the following error:

> 
> Msg 512, Level 16, State 1, Procedure cmt\_update, Line 17 [Batch Start
>  Line 8]  
> 
>  Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
> 
> 
> 

This error refers to this line:

```
IF (select pendent from deleted) = 0 AND (select pendent from inserted) = 1

```

While searching I've found that SQL Server trigger is executed by statement and not by row, causing this error only when I update multiple rows. 

I have tried multiple solutions like this one but they didn't worked:

```
IF (select pendent from comments c inner join deleted d on d.id = c.id) = 0 AND (select pendent from comments c inner join inserted i on i.id = c.id) = 1

```

None of the solutions that I found where like my example, because trigger only breaks when I compare the values, because the code of both inserts are with the correct syntax.

I've found that using cursors may help but I'm not managing to make code right to work with it, can anyone help me? Thanks!