Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Delete script

Posted on 2011-02-22
4
Medium Priority
?
352 Views
Last Modified: 2012-05-11
I would like to delete values in one table that don't exist in another.

for example
delete from glf_chart_acct where accnbri does not exist in table glf_ldg_acc_trans
What would be the correct syntax for this?
0
Comment
Question by:Matthew34
  • 2
4 Comments
 
LVL 8

Accepted Solution

by:
rushShah earned 668 total points
ID: 34957790
try this,
delete 
from glf_chart_acct a
LEFT JOIN glf_ldg_acc_trans t ON a.accnbri = t.accnbri
where t.accnbri is null

Open in new window

0
 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 1332 total points
ID: 34957798
delete from glf_chart_acct where NOT EXISTS (select accnbri from table glf_ldg_acc_trans)
0
 
LVL 24

Assisted Solution

by:jimyX
jimyX earned 1332 total points
ID: 34957813
or,
delete from glf_chart_acct where NOT EXISTS (select glf_ldg_acc_trans.accnbri from table glf_ldg_acc_trans where glf_ldg_acc_trans.accnbri = glf_chart_acct.accnbri)
0
 

Author Closing Comment

by:Matthew34
ID: 34957833
Thanks
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

971 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question