Solved

Delete script

Posted on 2011-02-22
4
340 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 167 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 333 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 333 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

744 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now