title: SQL Server : trigger on after insert into multiple tables
body: <p>In a SQL Server database that I am setting up, there are a few 1 to many tables that I would like to create the "many" table records after the parent record is inserted, inserting only the auto generated ID value and another value from the parent record.</p>
  
  <p>For instance:</p>
  
  <ul>
  <li>Table 1 (Parent): Auto_ID, Name, createby, createdatetime  </li>
  <li>Table 2 (Child): Auto_ID, Parent_Auto_ID, Col1, Col2, createby, createdatetime  </li>
  <li>Table 3 (Child): Parent_Auto_ID, Col1, createby, createdatetime  </li>
  </ul>
  
  <p>I already have:</p>
  
  <pre><code>CREATE TRIGGER [dbo].[ipamuserInsert] 
  ON [dbbo].[ipamuser]
  FOR INSERT
  AS
      SET NOCOUNT ON
  
      INSERT INTO [dbo].[ipamuserdefault]
          (ipamuserID, homepage, createby, createdatetime)
      VALUES
          SELECT 
              ipamuserID,
              NULL,
              createby,
              GETDATE()
          FROM 
              inserted
  
      INSERT INTO [dbo].[ipamextlink]
          (ipamuserID, link, createby, GETDATE())
      VALUES
          SELECT
              ipamuserID, null, createby, GETDATE()
          FROM
              inserted
      GO
  </code></pre>
  
  <p>Is this the right syntax, or do I need to declare a separate temp variable and store the ipamuserID and the createby values and use those instead?</p>