title: SQL Server Insert Data From Other table
body: <p>In my database i have tables:</p>
  
  <ul>
  <li>System Privileges (PrivilegesTable)</li>
  <li>Admins (AdminsTable) </li>
  <li>Admins Privileges (AdminsPrivilegesTable). </li>
  </ul>
  
  <p>I want to insert data in to AdminsPrivilegesTable after insert new admin data i will use trigger for this but i need query to take the admin ID And get all privileges iD From PrivilegesTable and insert it in to AdminsPrivilegesTable. I used this query but does not work.</p>
  
  <pre><code>INSERT INTO [AdminsPrivilegesTable]
             ([ID]
             ,[AdminID]
             ,[PrevlgID]
             ,[Status])
       VALUES
             ((SELECT ISNULL(MAX(ID)+1,1) FROM AdminsPrivilegesTable)
             ,(SELECT ID FROM Inserted)
             ,(SELECT ID FROM PrivilegesTable)
             ,0)
  </code></pre>