Delete Query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all

I have a temp table that contains EmployeeID #s. I want to use that to
delete a bunch of records from another table. The following is the SQL code
generated by my query. It keeps giving me an error asking to specify the
table I want to delete from:

DELETE EmployeeVacations.VID, EmployeeVacations.EmployeeID,
EmployeeVacations.VacType, EmployeeVacations.DaysRequested,
EmployeeVacations.From, EmployeeVacations.To, EmployeeVacations.To2,
EmployeeVacations.DayRequested, EmployeeVacations.DayApproved
FROM EmployeeVacations INNER JOIN [Temporary] ON
EmployeeVacations.EmployeeID = Temporary.EmployeeID;


I'd appreciate any help

Thanks
 
Forgot one line please add to end of query

where EmployeeVacations.EmployeeID = Temporary.EmployeeID

thank you
 
Another addition. I even tried the following :

DELETE EmployeeVacations.*
FROM EmployeeVacations
where EmployeeVacations.EmployeeID = Temporary.EmployeeID;

and I get a dialog box asking for the temporary.employeeID parameter

thanks
 
DELETE DISTINCTROW EmployeeVacations.EmployeeID,
FROM EmployeeVacations INNER JOIN [Temporary] ON
EmployeeVacations.EmployeeID = Temporary.EmployeeID;

If that doesn't work (it should) , then try
DELETE DISTINCTROW EmployeeVacations.EmployeeID,
FROM EmployeeVacations
WHERE EmployeeVacations.EmployeeID IN
(SELECT Temporary.EmployeeID FROM [Temporary] (
 
Hi John

The 1st one worked like a chrm after removing the comma on the 1st line. Now
I need to know why this did work and mine didn't. If you have a minute an
explanation would be enlightning.

Thanks
--
Alex


John Spencer said:
DELETE DISTINCTROW EmployeeVacations.EmployeeID,
FROM EmployeeVacations INNER JOIN [Temporary] ON
EmployeeVacations.EmployeeID = Temporary.EmployeeID;

If that doesn't work (it should) , then try
DELETE DISTINCTROW EmployeeVacations.EmployeeID,
FROM EmployeeVacations
WHERE EmployeeVacations.EmployeeID IN
(SELECT Temporary.EmployeeID FROM [Temporary] (


Alex said:
Hi all

I have a temp table that contains EmployeeID #s. I want to use that to
delete a bunch of records from another table. The following is the SQL
code
generated by my query. It keeps giving me an error asking to specify the
table I want to delete from:

DELETE EmployeeVacations.VID, EmployeeVacations.EmployeeID,
EmployeeVacations.VacType, EmployeeVacations.DaysRequested,
EmployeeVacations.From, EmployeeVacations.To, EmployeeVacations.To2,
EmployeeVacations.DayRequested, EmployeeVacations.DayApproved
FROM EmployeeVacations INNER JOIN [Temporary] ON
EmployeeVacations.EmployeeID = Temporary.EmployeeID;


I'd appreciate any help

Thanks
 
Whoops! Sorry about that comma.

The reason it worked was the inclusion of DISTINCTROW. I just removed all
the other references to the fields as they are really not needed in a delete
query.

I'm not sure why including the DistinctRow works. I do know that until
recent versions I did not need to use it, but that it often seems to be
needed.

Alex said:
Hi John

The 1st one worked like a chrm after removing the comma on the 1st line.
Now
I need to know why this did work and mine didn't. If you have a minute an
explanation would be enlightning.

Thanks
--
Alex


John Spencer said:
DELETE DISTINCTROW EmployeeVacations.EmployeeID,
FROM EmployeeVacations INNER JOIN [Temporary] ON
EmployeeVacations.EmployeeID = Temporary.EmployeeID;

If that doesn't work (it should) , then try
DELETE DISTINCTROW EmployeeVacations.EmployeeID,
FROM EmployeeVacations
WHERE EmployeeVacations.EmployeeID IN
(SELECT Temporary.EmployeeID FROM [Temporary] (


Alex said:
Hi all

I have a temp table that contains EmployeeID #s. I want to use that to
delete a bunch of records from another table. The following is the SQL
code
generated by my query. It keeps giving me an error asking to specify
the
table I want to delete from:

DELETE EmployeeVacations.VID, EmployeeVacations.EmployeeID,
EmployeeVacations.VacType, EmployeeVacations.DaysRequested,
EmployeeVacations.From, EmployeeVacations.To, EmployeeVacations.To2,
EmployeeVacations.DayRequested, EmployeeVacations.DayApproved
FROM EmployeeVacations INNER JOIN [Temporary] ON
EmployeeVacations.EmployeeID = Temporary.EmployeeID;


I'd appreciate any help

Thanks
 
Thanks a lot John
--
Alex


John Spencer said:
Whoops! Sorry about that comma.

The reason it worked was the inclusion of DISTINCTROW. I just removed all
the other references to the fields as they are really not needed in a delete
query.

I'm not sure why including the DistinctRow works. I do know that until
recent versions I did not need to use it, but that it often seems to be
needed.

Alex said:
Hi John

The 1st one worked like a chrm after removing the comma on the 1st line.
Now
I need to know why this did work and mine didn't. If you have a minute an
explanation would be enlightning.

Thanks
--
Alex


John Spencer said:
DELETE DISTINCTROW EmployeeVacations.EmployeeID,
FROM EmployeeVacations INNER JOIN [Temporary] ON
EmployeeVacations.EmployeeID = Temporary.EmployeeID;

If that doesn't work (it should) , then try
DELETE DISTINCTROW EmployeeVacations.EmployeeID,
FROM EmployeeVacations
WHERE EmployeeVacations.EmployeeID IN
(SELECT Temporary.EmployeeID FROM [Temporary] (


Hi all

I have a temp table that contains EmployeeID #s. I want to use that to
delete a bunch of records from another table. The following is the SQL
code
generated by my query. It keeps giving me an error asking to specify
the
table I want to delete from:

DELETE EmployeeVacations.VID, EmployeeVacations.EmployeeID,
EmployeeVacations.VacType, EmployeeVacations.DaysRequested,
EmployeeVacations.From, EmployeeVacations.To, EmployeeVacations.To2,
EmployeeVacations.DayRequested, EmployeeVacations.DayApproved
FROM EmployeeVacations INNER JOIN [Temporary] ON
EmployeeVacations.EmployeeID = Temporary.EmployeeID;


I'd appreciate any help

Thanks
 
Back
Top