title: SQL Server trigger with loop for multiple row insertion
body: <p>I've created trigger for my database which handles some insertion but when I add multiple values in 1 SQL query it doesn't work:</p>
  
  <pre><code>ALTER TRIGGER [dbo].[ConferenceDayTrigger]
  ON [dbo].[Conferences]
  AFTER INSERT
  AS 
  BEGIN
      DECLARE @ID INT
      DECLARE @dayC INT
      DECLARE @counter INT
  
      SET @counter = 1
      SET @ID = (SELECT  IDConference FROM Inserted)
      SET @dayC = (SELECT   DATEDIFF(DAY, start,finish) FROM Inserted)
  
      WHILE @counter &lt;= @dayC + 1 
      BEGIN
          EXEC AddConferenceDay @Id, @counter
          SET @counter = @counter +1
      END
  END
  </code></pre>
  
  <p>For single insertion it works ok. But what should I change/add to make it execute for each row of inserted values?</p>