I posted under a separate thread earlier, however had to delete due to accidentally posting some real user data.
My issue was that I was trying to compare two combinations of data, Table A.Job Code + Table A.Dept + Table A.Role = Table B.Job Code + Table B.Dept + Table B.Role. If Table A.Role did not exist in Table B, or any piece of the combination did not match, I needed that record from Table A inserted into Table C.
@theDBguy was able to provide me with the following query to resolve my issue (note: it does not include the INTO portion of SQL):
And if you are wondering about the characters in front of APP_USERNAME, apparently those are included in CSV files run from SQL Server which indicate blank space before the word. My SQL people have looked into it and can't find a problem, but that's why those are there.
My issue was that I was trying to compare two combinations of data, Table A.Job Code + Table A.Dept + Table A.Role = Table B.Job Code + Table B.Dept + Table B.Role. If Table A.Role did not exist in Table B, or any piece of the combination did not match, I needed that record from Table A inserted into Table C.
@theDBguy was able to provide me with the following query to resolve my issue (note: it does not include the INTO portion of SQL):
Code:
SELECT Table A.APP_USERNAME, Table A.Job_Code, Table A.Dept_ID, Table A.Roles
FROM Table A LEFT JOIN Table B ON (Table A.Dept_ID = Table B.DepartmentID) AND (Table A.Job_Code = Table B.[Job Code]) AND (Table A.Roles = Table B.Access_name)
WHERE (((Table B.[Job Code]) Is Null))
ORDER BY Table A.APP_USERNAME, Table A.Job_Code, Table A.Dept_ID, Table A.Roles;
And if you are wondering about the characters in front of APP_USERNAME, apparently those are included in CSV files run from SQL Server which indicate blank space before the word. My SQL people have looked into it and can't find a problem, but that's why those are there.