sql server 2008 - MERGE leads to 'Subquery returned more than 1 value' error in trigger -


The trigger below is on the table and I'm using it to update.

trigger

This trigger will update a type ID column based on the entered or any other column ... Is bound to type on the badly prepared table

ID column is a identity column.

Update Statement

  Merge using Table 1 typing in Table 1 Table1.TypeName = TypeTable.TypeName is matched when updated SET TypeID = TypeTable.TypeID;   

I get an error when the trigger is enabled:

Subkey returned more than 1 value when subquery = =,! =, & Lt;, & lt; =, & Gt ;, & gt; = Or when subquery is used as expression, then it is not allowed

I found this post describing that the issue is that the trigger in the table is only available at the same time A record was designed for. I disabled the trigger and was able to successfully update. My question is how to write the trigger, as there is no problem on large scale updates like this.

Some things: Your trigger has been assumed that all operations affect only one line. The way in which the contains is inserted in the table, instead of trying to do a variable with the id value, instead of trying to do stuff, who knows what the line is, besides entered Investigation against (which is EXISTS missing in your example) is not really necessary if <0> is entered in Lines will still be updated then.

  ALTER TRIGGER [dbo] [TypeIDInsert] ON [dbo] [Table 1] After INSERT, set the notebook as the beginning of the update; Update T Set T. Type = Case I.TypeName When 'value1' then 1 'value2' then 2 when 'value 3' then end from 3 or 0 dbs Eventually insert as T. = I.ID; Go END    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -