Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Query

Status
Not open for further replies.

mentasses

Technical User
Mar 23, 2004
29
GB
My update query records the registration number, make and model of an employees company vehicle on his personnel record from a vehicle register where the switch CURRENT is ='T'(True) However, if the employee surrenders his vehicle for a car allowance I need to clear the vehicle details from the personnel record. The current query is:

UPDATE EMPLOYEE.dbo.RECORD
SET EMPLOYEEMAKE = VEHICLEMAKE
EMPLOYEEMODEL = VEHICLEMODEL
EMPLOYEEREG = VEHICLEREG
FROM EMPLOYEE etc.
ON EMPLOYEEREG = VEHICLEREG
WHERE CURRENT ='T'

I need to clear EMPLOYEEMAKE, MODEL & REG WHERE CURRENT is NOT LIKE 'T'

How do I add the delete part?
 
How does this work for you? Good luck!

Code:
UPDATE EMPLOYEE.dbo.RECORD
SET EMPLOYEEMAKE = NULL
    EMPLOYEEMODEL = NULL
    EMPLOYEEREG = NULL
FROM EMPLOYEE etc.
ON EMPLOYEEREG = VEHICLEREG
WHERE CURRENT <> 'T'

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
UPDATE EMPLOYEE.dbo.RECORD
SET EMPLOYEEMAKE = NULL, MODEL = NULL, REG = NULL
WHERE [CURRENT] != 'T'

DBomrrsm

Or of you need to delete the entire row for these

DELETE FROM EMPLOYEE.dbo.RECORD
WHERE [CURRENT] != 'T'

DBomrrsm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top