title: How do I migrate Data from one Database Table into another SQL?
body: <p>I'm really new at this whole SQL DB migration stuff and I'm ready to learn. </p>
  
  <p>I have 2 different Databases and both of them have a User Table, called <code>HtUser</code> in one destination db and <code>HTUser</code> in the source db. </p>
  
  <p>I want to create a script that is copying the data from specific columns in the source db that would be <code>firstName, lastName, email</code> and in my destination db that would be <code>FirstName, LastName, Email</code> and a "special field" <code>UserName</code> contains ch + two letters from the <code>firstName</code> and three from the <code>lastName</code>.  </p>
  
  <pre><code>    INSERT  INTO HolidayTracker.dbo.HtUser(FirstName,LastName,Email,UserName,AdAccount,AdDomain)
  SELECT firstName,lastName,email,'CH'+LEFT(firstName,2)+LEFT(lastName,3),'EUROPE\'+LEFT(firstName,2)+LEFT(lastName,3),''
  FROM HolidayTracker.dbo.HTUser U1
  WHERE NOT EXISTS ( SELECT 1 FROM HolidayTracker.dbo.HTUser U2 WHERE U2.FirstName = U1.firstName AND U2.LastName = U1.lastName AND U2.email = U1.Email);
  
  
  
  
  
  
  
  
  INSERT INTO HolidayTracker.dbo.HtUser(FirstName,LastName,Email,UserName,AdAccount,AdDomain)
  SELECT firstName,lastName,email,'CH'+LEFT(firstName,2)+LEFT(lastName,3),'EUROPE\'+LEFT(fistName,2)+LEFT(lastName,3),''
  FROM HolidayTracker.dbo.HTUser u1
      LEFT JOIN HolidayTracker.dbo.HtUser u2 ON u1.firstName = u2.FirstName AND u1.lastName = u2.LastName AND u1.email = u2.Email
      WHERE u2.FirstName IS NULL
      AND u2.LastName IS NULL
      AND u2.Email IS NULL;
  </code></pre>