Connecting Tech Pros Worldwide Forums | Help | Site Map

I would like to delete records found in an unmatched query from the originating table

Member
 
Join Date: Oct 2006
Posts: 55
#1: Aug 23 '07
Is there a way to automate this process?

I have a query that finds the "Drop Offs" by doing an unmatch query against the hard table and the live table.

I want to automatically pull these "Drop Offs" out of the Hard table.

my sql for the query I am running follows:

1st Query - pulls the data from the live tables.

SELECT vewEmployeeLogin.PersonID, vewEmployeeLogin.User AS LOGIN, " " AS [PASSWORD], vewEmployeeLogin.[First Name] AS [FIRST NAME], vewEmployeeLogin.[Last Name] AS [LAST NAME], Max(IIf([TELECOMMTYPEID]=2,[TELECOMMVALUE],"")) AS EMAIL, Max(IIf([TELECOMMTYPEID]=1,[TELECOMMVALUE],"")) AS PHONE, "YES" AS EmployeeActive
FROM ((tblEmployee LEFT JOIN tblPerson_Telecomm ON tblEmployee.PersonId = tblPerson_Telecomm.PersonID) LEFT JOIN tblTelecomm ON tblPerson_Telecomm.TelecommID = tblTelecomm.TelecommID) RIGHT JOIN vewEmployeeLogin ON tblEmployee.PersonId = vewEmployeeLogin.PersonID
GROUP BY vewEmployeeLogin.PersonID, vewEmployeeLogin.User, vewEmployeeLogin.[First Name], vewEmployeeLogin.[Last Name], "YES";

2nd query - compairs data in Hard Table to the Live table and spits out the unmatched ones.

SELECT tblCRCTPanasonicLMSOriginal.PersonID, tblCRCTPanasonicLMSOriginal.LOGIN, tblCRCTPanasonicLMSOriginal.PASSWORD, tblCRCTPanasonicLMSOriginal.[FIRST NAME], tblCRCTPanasonicLMSOriginal.[LAST NAME], tblCRCTPanasonicLMSOriginal.EMAIL, tblCRCTPanasonicLMSOriginal.PHONE, tblCRCTPanasonicLMSOriginal.STATUS
FROM tblCRCTPanasonicLMSOriginal LEFT JOIN qryCRCTPanasonicLMS ON tblCRCTPanasonicLMSOriginal.PersonID = qryCRCTPanasonicLMS.PersonID
WHERE (((qryCRCTPanasonicLMS.PersonID) Is Null));

Hard Table is the results of the 1st query that I pulled a week ago.

Live Table is a combination of several tables on and SQL Server - which is what the 1st query pulls.


Any help would be nice in creating some sort of delete query to delete the records pulled by the 2nd query from the Hard Table.

Thanks!
Sophie
missinglinq's Avatar
Moderator
 
Join Date: Nov 2006
Location: Richmond, Virginia USA
Posts: 2,997
#2: Aug 23 '07

re: I would like to delete records found in an unmatched query from the originating table


You have inadvertently posted your question in the Articles section rather than in the Forum section of our site, so I have moved it across to the Forum for you.

Linq ;0)>
Member
 
Join Date: Oct 2006
Posts: 55
#3: Aug 23 '07

re: I would like to delete records found in an unmatched query from the originating table


Thank you very much! I was wondering why I couldn't find it!
Reply