I'm trying to insert only new records into a table and wanted to know if this was the best solution. I know if I was only comparing one field in the different tables I could do a not in (select distinct etc...) but the new value is based on two fields creating the unique value. This is the query I'm considering using. Any better ways of doing this?
INSERT INTO SGroups(DepartmentID, SGroupName)
SELECT DISTINCT A.Department, A.SGroup
FROM EmpData_Dump A LEFT JOIN SGroups B ON A.Department = B.DepartmentID and A.SGroup = B.SGroupName
WHERE B.DepartmentID IS NULL AND B.SGroupName is null