[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 109
  • Last Modified:

delete values from a table when joined

I am trying to delete orphan objects in my table that I located in the following SQL statement

SELECT r.*,h.*
FROM dbo.tblOrgHours h
             left JOIN tblOrgRegistrations r ON r.RegID = h.RegID  -- Change Foreign Key as appropriate
WHERE r.RegID IS NULL

How would I delete the values found in my tblOrgHours table?
0
al4629740
Asked:
al4629740
1 Solution
 
Anthony PerkinsCommented:
DELETE h
FROM dbo.tblOrgHours h
             LEFT JOIN tblOrgRegistrations r ON r.RegID = h.RegID
WHERE r.RegID IS NULL
0

Featured Post

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now