title: Creating an insert statement to copy existing data from a SQL table
body: <p>I need to provide a user access to 170 different department codes. The UserAccess table contains the permissions and to give the access I just have to input a new line with an employee ID in the UserId column and a department code in the DepartmentCode column. The problem is I don’t want to manually enter 170 different insert statements. I’m trying to work out how to copy an existing user who has already the access to all the department codes.</p>
  
  <p>dbo.Departments</p>
  
  <ul>
  <li>DepartmentCode (PK, char(5), not null)</li>
  <li>Description (varchar(50), null)</li>
  </ul>
  
  <p>dbo.UserAccess</p>
  
  <ul>
  <li>UserId (varchar(10), not null)</li>
  <li>DepartmentCode (FK, char(5), not null)</li>
  </ul>