title: Subquery returned more than 1 value. this is not permitted when the subquery follows = or when the subquery is used as an expression?
body: <p>I want to update multiple tables and values after inserting values in one table so I created a trigger. It works fine for inserts of one row, but as soon I insert more rows, SQL Server gives me  following error:</p>
  
  <blockquote>
    <p>subquery returned more than 1 value. this is not permitted when the subquery follows =  or when the subquery is used as an expression?</p>
  </blockquote>
  
  <p>Here is my trigger:</p>
  
  <pre><code>CREATE TRIGGER [dbo].[tbl_Sales_ForInsert]
  ON [dbo].[SALES] 
  FOR INSERT
  AS
  BEGIN
    DECLARE @ITEMMODEL varchar(100)
  
    SELECT @ITEMMODEL = ITEM_MODEL FROM inserted
  
    UPDATE SALES 
    SET PROFIT = TOTAL_PRICE - (SELECT QUANTITY FROM SALES WHERE ITEM_MODEL = @ITEMMODEL) * (SELECT RATE FROM ITEM_DETAILS WHERE ITEM_MODEL = @ITEMMODEL) 
    WHERE ITEM_MODEL = @ITEMMODEL
  
    UPDATE ITEM_DETAILS 
    SET QUANTITY = QUANTITY - (SELECT QUANTITY FROM SALES WHERE ITEM_MODEL = @ITEMMODEL) 
    WHERE ITEM_MODEL = @ITEMMODEL
  
    --UPDATE ITEM_DETAILS SET AMOUNT = AMOUNT - (SELECT RATE FROM ITEM_DETAILS WHERE ITEM_MODEL=@ITEMMODEL) * (SELECT QUANTITY FROM SALES WHERE ITEM_MODEL=@ITEMMODEL) where ITEM_MODEL=@ITEMMODEL
  END
  </code></pre>
  
  <p>As I insert data in <code>SALES</code> table for 1st time the update got successful but for 2nd time it gives me above error remember <code>ITEM_MODEL</code> is foreign key constraint in SALES table.</p>
  
  <p>I have been suffering with this error can anyone help me please?</p>